GCC/32Bit architecture
class B
{
int x,y;
};
class D1: public virtual B
{
int z;
};
class D2; public virtual B
{
int z;
public:
virtual void func(){}
};
int main() {
B b; D1 d1; D2 d2;
cout<<sizeof(b)<<endl;
cout<<sizeof(d1)<<endl;
cout<<sizeof(d2)<<endl;
return 0;
}
As per my understanding, B has 2 integer: 8 bytes D1: offet to B(B _vPtr), x,y,z => 16. D2: B _vBase, VPTR, x, y => 16
Ans i am getting is 8, 24, 24.
What is the size of the class and how memory allocated for this classes.
How is Vptr and Vtable managed in these cases.