虛表注意display中打印成員變量時(shí)需注意(eg:string可能出錯(cuò))
當(dāng)基類中沒有子類對(duì)應(yīng)虛函數(shù),調(diào)試窗口不顯示,需打印出來
//#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);//}