title: How to call an object constructor inside another constructor?
body: <p>I have an abstract class <code>A</code> and a class <code>B</code> with the constructor:</p>
  
  <pre><code>B(A &amp;a) {...}
  </code></pre>
  
  <p>Now, I create these objects in the main program as follow:</p>
  
  <pre><code>int main(){
    std::unique_ptr&lt;A&gt; a = make_A();//don't mind make_A()
    if(a==null)
      a = make_default_A();
    B b (*a); 
  }
  </code></pre>
  
  <p>Now I created a class which setups the system:</p>
  
  <pre><code>class System{
  public:
    System();
  private:
    B b;
    std::unique_ptr&lt;A&gt; a;
  }
  </code></pre>
  
  <p>And the constructor is:</p>
  
  <pre><code>System(){
    a = make_A();
    if(a==null)
      a = make_default_A();
    b(*a);
  }
  </code></pre>
  
  <p>Obviously this is wrong because I can't call <code>B</code>'s constructor as in the code above, but I can't figure out how to do this. The only solution that came to my mind is to use <code>std::unique_ptr&lt;B&gt; b;</code> instead of <code>B b;</code> and then call <code>b = make&lt;B&gt; (*a);</code>.</p>