title: Initialize Object as member of another class
body: <p>I just want to understand the flow how it happens as am new to c++.</p>
  
  <p>Let me elaborate my problem statement. </p>
  
  <pre><code>class test1 {
  public:
      test1() {
          cout &lt;&lt; " test1::constructor called" &lt;&lt; endl;
      }
      ~test1() {
          cout &lt;&lt; " test1::destrcutor called" &lt;&lt; endl;
      }
  };
  
  class test2 {
  public:
      test2() {
          cout &lt;&lt; " test2::constructor called" &lt;&lt; endl;
      }
      ~test2() {
          cout &lt;&lt; " test2::destrcutor called" &lt;&lt; endl;
      }
  };
  
  class derived :public test1, public test2 {
      test2 t2;
      test1 t1;
  public:
      derived() {
          cout &lt;&lt; " derived constructor called" &lt;&lt; endl;
      }
      ~derived() {
          cout &lt;&lt; "derived destructor called" &lt;&lt; endl;
      }
  };
  
  int main() {
      derived d;
      return 0;
  }
  </code></pre>
  
  <p>The output of the above program shows</p>
  
  <pre><code>   test1::constructor called
     test2::constructor called
     test2::constructor called
     test1::constructor called
     derived constructor called
     derived destructor called
     test1::destrcutor called
     test2::destrcutor called
     test2::destrcutor called
     test1::destrcutor called
  </code></pre>
  
  <p>So here my question is at what points it called the constructor of the member variables in derived class as I have not put any initializer for the same.</p>