打印虚表 -电脑资料
虚表注意display中打印成员变量时需注意(eg:string可能出错)
当基类中没有子类对应虚函数,调试窗口不显示,需打印出来
//#include<iostream>//using namespace std;//typedef void(*Fun)();//class AA//{//public:// virtual void Fun1()// {// cout << "AAFun1()" << endl;// }// virtual void Fun2()// {// cout << "AAFun2()" << endl;// }//};//class BB :public AA//{//public:// virtual void Fun1()// {// cout << "BBFun1()" << endl;// }// virtual void Fun3()// {// cout << "BBFun3()" << endl;// }// virtual void Fun4()// {// cout << "BBFun4()" << endl;// }//};//void PrintVTable(int* vTable)//{// for (int i = 0; vTable[i] != 0; ++i)// {// Fun f = (Fun)vTable[i];// f();// }//}//void Test1()//{// AA a;// BB b;// int* vTable = (int *)*(int*)&a;// PrintVTable(vTable);//// vTable = (int *)*(int*)&b;// PrintVTable(vTable);//}