title: Constructors calling in c++ (inherited classes)
body: <pre><code>#include &lt;iostream&gt;
  
  class A
  {
  public:
    A()  { std::cout &lt;&lt; "A's constructor called\n"; }
  };
  
  class B
  {
  public:
    B()  { std::cout &lt;&lt; "B's constructor called\n"; }
  };
  
  class C: public B, public A  // Note the order
  {
  public:
    C()  { std::cout &lt;&lt; "C's constructor called\n"; }
  };
  
  int main()
  {
      C c;
      return 0;
  }
  </code></pre>
  
  <p>Why is the constructor of class <code>A</code> and <code>B</code> called, when a new instance of <code>C</code> is created?</p>
  
  <p>Output is</p>
  
  <pre>
  B's constructor called
  A's constructor called
  C's constructor called
  </pre>