CF:virtual继承CBase和CBase2,vbtable此时的项便有两个。此时依照继承的顺序,而不是依照类的声明顺序
  class CF: virtual public CBase2, virtual public CBase
  {
  };
  输出:
  class CF size(12):
  +---
  0 | {vbptr}
  +---
  +--- (virtual base CBase2)
  +---
  +--- (virtual base CBase)
  4 | {vfptr}
  8 | m_valuable
  +---
  CF::$vbtable@:
  0 | 0
  1 | 4 (CFd(CF+0)CBase2)
  2 | 4 (CFd(CF+0)CBase)
  CF::$vftable@:
  | -4
  0 | &CBase::fun
  vbi:    class  offset o.vbptr  o.vbte fVtorDisp
  CBase2       4       0       4 0
  CBase       4       0       8 0
  总结:
  继承方式:非virtual继承:导入各个父类的结构(依照父类声明的顺序,从上到下),自身member在后
  重写virtual方法:更新该方法早定义的类的vftable
  新的virtual方法:在左父类的vftable添加
  继承方式:有virtual继承:在自身member后添加virtual父类的结构(依照子类继承的顺序从左到右)。同一时候在前面添加vbtable(假设没有的话),添加一项指向父类结构
  重写virtual方法:更新该方法的早定义的类的vftable
  新的virtual方法:在自身前面添加vftable(假设没有的话),在自己的vftable添加
  附 全部源代码:
#ifndef TEST_CBASE_H
#define TEST_CBASE_H
class CBase
{
public:
CBase();
explicit CBase(int valuabel);
~CBase();
virtual void fun(void) {}
private:
int m_valuable;
};
class CDerived: public CBase
{
public:
void fun(void) { }
virtual void vfun(void) { }
public:
int m_derived;
};
class CDerived2: virtual public CBase
{
public:
void fun(void) { }
virtual void vfun(void) { }
public:
int m_derived;
};
class CDerived3: virtual public CBase
{
public:
void fun(void) { }
public:
int m_derived3;
};
class CGDerived: public CDerived2, public CDerived3
{
public:
void vfun() { }
virtual void vgfun() { }
public:
int m_gd;
};
class CGG: public CGDerived
{
public:
int m_kc;
};
class CBase2
{
};
class CD2: virtual public CBase2
{
};
class CE: public CD2, public CDerived2
{
};
class CF: virtual public CBase2, virtual public CBase
{
};
#endif//TEST_CBASE_H