title: Print layout of C++ object with g++ compiler
body: <p>Is there a way to print the layout of a C++ object using the g++ compiler or any other means. 
  A simplified example (assuming int takes 4 bytes)</p>
  
  <pre><code>class A{
    int a;
  };
  
  class B:public A{
    int b;
  }
  </code></pre>
  
  <p>so the output would be </p>
  
  <pre><code>A-
  0      4
  +  a   +
  
  B-
  0      4      8
  + A.a  +  b   +
  </code></pre>
  
  <p>It would be useful to understand the layout of objects (in my case virtual machine code).</p>
  
  <p>Thanks in advance.</p>
  
  <p>Regards,
  Zaheer</p>