VC6编译
class A
{
public:
int x;
public:
virtual void funA() { }
};
class B : virtual public A
{
public:
int y;
public:
virtual void funA() { }
virtual void funB() { }
};
sizeof(B)=20 // because of B::vptr+vbptr+B::y+A::vptr+A::x = 5*4
class A
{
public:
int x;
public:
virtual void funA() { }
};
class B : virtual public A
{
public:
int y;
public:
B() {}
virtual void funB() { }
};
sizeof(B)=20 // because of B::vptr+vbptr+B::y+A::vptr+A::x = 5*4
class A
{
public:
int x;
public:
virtual void funA() { }
};
class B : virtual public A
{
public:
int y;
public:
B() {}
virtual void funA() { }
virtual void funB() { }
};
sizeof(B)=24
我不明白,为什么会是 24 岁???我认为他们是一样的!