虚拟单一继承下基类和派生类起始地址不同.
// VC++2005 #include <stdio.h> class Base { }; class Derived: public Base { }; class VirtualDerived: virtual public Base { }; int main() { Base* pB = NULL; Derived* pD = new Derived; pB = pD; printf("sizeof(Base) = %u/n",sizeof(Base)); printf("sizeof(Derived) = %u/n",sizeof(Derived)); printf("pD is 0x%p./n",pD); printf("pB is 0x%p./n",pB); delete pD; pD = NULL; pB = NULL; printf("/n"); VirtualDerived* pVD = new VirtualDerived; pB = pVD; printf("sizeof(Base) = %u/n",sizeof(Base)); printf("sizeof(VirtualDerived) = %u/n",sizeof(VirtualDerived)); printf("pVD is 0x%p./n",pVD); printf("pB is 0x%p./n",pB); delete pVD; pVD = NULL; return 0; } // end of main // 控制台输出 sizeof(Base) = 1 sizeof(Derived) = 1 pD is 0x003B5EF0. pB is 0x003B5EF0. sizeof(Base) = 1 sizeof(VirtualDerived) = 4 pVD is 0x003B5EF0. pB is 0x003B5EF4.