title: size of derived class
body: <p>I am new to C++ programming, in the below code i am using virtual inheritance so size of derived class is showing 24 bytes but i am not getting how it is so please help me how exactly it is. </p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  using namespace std;
  
  class BaseClass
  {
        private : int a, b;
        public :
    BaseClass()
    {
      a = 10;
      b = 20;
    }
    virtual int area()
    {
      return 0;
    }
  };
  
  class DerivedClass1 : virtual public BaseClass
  {
    int x;
        public:
    virtual void simple()
    {
      cout &lt;&lt; "inside simple" &lt;&lt; endl;
    }
  };
  
  int main()
  {
     DerivedClass1 Obj;
     cout &lt;&lt; sizeof(Obj) &lt;&lt; endl;
     return 0;
  }
  </code></pre>