看不懂的程序。。。帮忙解释下、谢谢
#include <iostream>using namespace std;
class Base
{
public:
virtual void VirtualFunction1() { cout << "Base::VirtualFunction1()" << endl; }
virtual void VirtualFunction2() { cout << "Base::VirtualFunction2()" << endl; }
void PlaneFunction() { cout << "Base::PlaneFunction()" << endl; }
int Data1;
int Data2;
Base() : Data1(10), Data2(20){}
};
typedef void(*VFP)(void);
int main()
{
Base obj;
int* p1 = (int*)*((int*)&obj+0)+0;
int* p2 = (int*)*((int*)&obj+0)+1;
VFP vfp1 = (VFP)*p1;
VFP vfp2 = (VFP)*p2;
printf("%p != %p\n", &Base::VirtualFunction1, vfp1);
printf("%p != %p\n", &Base::VirtualFunction2, vfp2);
}
注释红色部分即可、、、