看了pengzhixi (如果你想了解就点这里就可以看见虚函数内在的东西了)的博客,特意留下来给以后自己看。 抄了一段代码给自己看的。。 #include <iostream> using namespace std; class Base { public: virtual void f() { cout << "Base::f" << endl; } virtual void g() { cout << "Base::g" << endl; } virtual void h() { cout << "Base::h" << endl; } }; typedef void(*Fun)(); int main() { Base b; Fun pFunf = NULL; Fun pFung = NULL; Fun pFunh = NULL; cout << "虚函数表地址:" << (int*)(&b) << endl; cout << "虚函数表 — 第一个函数地址:" << (int*)*(int*)(&b) << endl; pFunf = (Fun)*((int*)*(int*)(&b+0));// Base::f() 与这个(int*)*(int*)(&b)等价 pFunf(); pFung =(Fun)*((int*)*(int*)(&b)+1); // Base::g() pFung(); pFunh =(Fun)*((int*)*(int*)(&b)+2); // Base::h() pFunh(); system("pause"); return 0; } C++博大精深。