title: Constructor call hierarchy
body: <p>I'm having a tricky time with calling rules for constructors in a type hierarchy. Here is what I do:</p>
  
  <pre><code>class A{
  protected:
      int _i;
  public:
      A(){i = 0;}
      A(int i) : _i(i){}
      virtual ~A(){}
      virtual void print(){std::cout&lt;&lt;i&lt;&lt;std::endl;}
  };
  
  class B : virtual public A{
  protected:
      int _j;
  public:
      B() : A(){_j = 0;}
      B(int i, int j) : A(i), _j(j){}
      virtual ~B(){}
      virtual void print(){std::cout&lt;&lt;i&lt;&lt;", "&lt;&lt;j&lt;&lt;std::endl;}
  };
  
  class C : virtual public B{
  protected:
      int _k;
  public:
      C() : B(){_k = 0;}
      C(int i, int j, int k} : B(i,j), _k(k){}
      virtual ~C(){}
      virtual void print(){std::cout&lt;&lt;i&lt;&lt;", "&lt;&lt;j&lt;&lt;", "&lt;&lt;k&lt;&lt;std::endl;}
  };
  
  int main(){
      C* myC = new C(1,2,3);
      myC-&gt;print();
      delete myC;
      return 0;
  }
  </code></pre>
  
  <p>Now, I would like to have new C(1,2,3) call the constructor of B(1,2) which then in turn should call the constructor A(1) to store _i=1, _j=2, _k=3. When creating the instance myC of the class C, for some reason I don't understand, however, the first constructor to be called is the standard constructor of A, i.e., A::A(); This obviously leads to wrong results, as the protected variable _i is assigned the value 0. The constructor A(1) is never called. Why is this so? I find this very counter intuitive. Is there some way to avoid explicitly calling all constructors within the type-hierarchy to achieve the desired behavior?</p>
  
  <p>Thx for the help!</p>