title: What does a C++ compiler do to create an object?
body: <p>In C code like such:</p>
  
  <pre><code>{
     int i = 5;
     /* ....... */
  }
  </code></pre>
  
  <p>The compiler will replace the code by moving the Stack pointer down (for stacks growing down) by the size of an int, and places the value 5 in that memory place.</p>
  
  <p>Similarly, in C++ code, what does the compiler do if an object is created? For example: </p>
  
  <pre><code>class b
  {
     public :
             int p;
             virtual void fun();
  };
  
  main()
  {
     b   obj;
  }
  </code></pre>
  
  <p>What will the compiler do for the above code? Can anyone explain when memory is allocated, and when memory for the virtual table is allocated, and when the default constructor is called?</p>