????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