Code: CPP
/******************************/
class A
{
private:
  int a;
  char b;
};

class B
{
private:
  char b;
};

int main()
{
  A a;
  B b;
  cout<<sizeof(a)<<"  "<<sizeof(b)<<endl;
  return 0;
}
/******************************************/
What will be the output of the above program?
The output will be,-
8 1
Why?...
















In class B, 1 byte is as usual allocated for char 'b'. But in case of class A,
4 bytes for integer 'a' and next 4 bytes for char 'b'. This is because of packaging format.