title: Constructor calling sequence
body: <p>Example 1:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class A
  {
  public:
      A(int a)
      {
          std::cout &lt;&lt; "A: " &lt;&lt; a &lt;&lt; '\n';
      }
  
        A()
      {
          std::cout &lt;&lt; "A" &lt;&lt;'\n';
      }
  };
  
  class B: public A
  {
      private:
      int b;
      A a1;
  public:
      B(int a, double b)
      : a1(a)
      {
          std::cout &lt;&lt; "B: " &lt;&lt; b &lt;&lt; '\n';
      }
  
  };
  
  class C: public B
  {
  public:
      C(int a , double b , char c)
      : B(a, b)
      {
          std::cout &lt;&lt; "C: " &lt;&lt; c &lt;&lt; '\n';
      }
  };
  
  int main()
  {
      C c(5, 4.3, 'R');
  
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>A
  A: 5
  B: 4.3
  C: R
  </code></pre>
  
  <p>Example 2:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class A
  {
  public:
      A(int a)
      {
          std::cout &lt;&lt; "A: " &lt;&lt; a &lt;&lt; '\n';
      }
  
        A()
      {
          std::cout &lt;&lt; "A: " &lt;&lt;'\n';
      }
  };
  
  class B: public A
  {
      private:
      int b;
      A a1;
  public:
      B(int a, double b)
      : A(a)
      {
          std::cout &lt;&lt; "B: " &lt;&lt; b &lt;&lt; '\n';
      }
  
  };
  
  class C: public B
  {
  public:
      C(int a , double b , char c)
      : B(a, b)
      {
          std::cout &lt;&lt; "C: " &lt;&lt; c &lt;&lt; '\n';
      }
  };
  
  int main()
  {
      C c(5, 4.3, 'R');
  
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>A: 5
  A: 
  B: 4.3
  C: R
  </code></pre>
  
  <p>What I understand from CPP is that the constructors of the base classes are called first then the members are initialized and finally the constructor of the derived class is called.Then Why am I not getting the first 2 lines of the output same ?</p>