探究C++对象模型 (三)

2014-11-24 02:27:53 · 作者: · 浏览: 7
truct TypeDescriptor* pTypeDescriptor; //TypeDescriptor of the complete class

struct RTTIClassHierarchyDescriptor* pClassDescriptor; //describes inheritance hierarchy


};


int main( )
{
Aclass* ptra=new Bclass;
int ** ptrvf=(int**)(ptra);

RTTICompleteObjectLocator str = *((RTTICompleteObjectLocator*)(*((int*)ptrvf[0]-1)));

//abstract class name from RTTI
string classname(str.pTypeDescriptor->name);
classname=classname.substr(4,classname.find("@@")-4);
cout< system("pause");
return 0;
}