Hi,
pls try to observe the size(i.e. total) of object for below program and in different cases as commented out.
#include<iostream>
using namespace std;
class B
{
int x; // try by commenting either data member and observe the object size
int *p;
public:
virtual void show(){}
};
int main()
{
B o;
cout << sizeof(o)<< endl;
return 0;
}
Individually x contibute 4 byte and p contribute 8 byte but both together make object size to 16 byte, why it is.
Thanks
dipesh udhlani