Can somebody help me with what all data and in which order is stored in class object?
#include <iostream>
using namespace std;
class A{
public:
A(){}
virtual ~A(){}
};
class B{
public:
B(int i):_i(i){}
~B(){}
private:
int _i;
};
class C{
public:
C(int i):_i(i){}
virtual ~C(){}
private:
int _i;
};
int main()
{
cout << "SIZEOF A : " << sizeof(A) << endl;
cout << "SIZEOF B : " << sizeof(B) << endl;
cout << "SIZEOF C : " << sizeof(C) << endl;
return 0;
}
Output:
SIZEOF A : 8 SIZEOF B : 4 SIZEOF C : 16
Why Sizeof(C) is 16 and not 12 ?