void PrintClassName(void *p)
{
type_info *** vtable = (type_info
***)(*(int*)p);
type_info ** v1 = vtable[-1];
type_info * v =
v1[3];
printf("printName: %s\n", v->name());
}
前提:该类必须有virtual 成员
例如:
class class1
{
char a;
double b;
public:
virtual
~class1(){}
};
时间: 2024-11-09 08:12:57