The sample code are as follow:
class A
{
public:
int k;
virtual int f();
};
class B:public virtual A
{
public:
virtual int a();
};
int main()
{
cout<<sizeof(A)<<sizeof(B);
}
It prints
8 12
It seems class B
has its own new virtual function table.
If class A
changes to:
class A
{
public:
virtual int f();
};
It prints
4 4
Could anyone explain the reason?