本文整理汇总了C++中BaseClass::function2方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseClass::function2方法的具体用法?C++ BaseClass::function2怎么用?C++ BaseClass::function2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseClass
的用法示例。
在下文中一共展示了BaseClass::function2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
cout<<"********BaseClass b = BaseClass()************\n";
BaseClass* b = new BaseClass();
cout<<"Address of Object = "<<(int*)b<<endl;
for(int i=0;i<sizeof(BaseClass)/4;++i)
cout<<"Memory["<<i<<"] "<<*((int**)(b)+i)<<endl;
cout<<"Address of VTable = "<<*(int**)(b)<<endl;
for(int i=0;i<3;++i)
cout<<"Memory["<<i<<"] "<<*(*(int***)(b)+i)<<endl;
cout<<"Address of function1 = "<<**(int***)(b)<<endl;
cout<<"Address of function2 = "<<*(*(int***)(b)+1)<<endl;
b->function1();
b->function2();
cout<<"\n********SubClass s = SubClass()************\n";
SubClass* s = new SubClass();
//SubClass* s = dynamic_cast<SubClass*>(b1);
cout<<"Address of Object = "<<(int*)s<<endl;
for(int i=0;i<sizeof(SubClass)/4;++i)
cout<<"Memory["<<i<<"] "<<*((int**)(s)+i)<<endl;
cout<<"Address of VTable = "<<*(int**)(s)<<endl;
for(int i=0;i<3;++i)
cout<<"Memory["<<i<<"] "<<*(*(int***)(s)+i)<<endl;
cout<<"Address of function1 = "<<**(int***)(s)<<endl;
cout<<"Address of function2 = "<<*(*(int***)(s)+1)<<endl;
s->function1();
s->function2();
cout<<"\n********Class c = Class()************\n";
Class* c = new Class();
cout<<"Address of object: "<<(int*)c<<endl;
//cout<<"Memory[0]: "<<*(int**)(c)<<endl;
for(int i=0;i<sizeof(Class)/4;++i)
cout<<"Memory["<<i<<"] "<<*((int**)(c)+i)<<endl;
c->function1();
return 0;
}