title: What pattern to use for the following scenario?
body: <p>I have the following class: </p>
  
  <pre><code>class Base {
  public:
      Base(string name) {
          agg = new Aggregate(name);
      }
  private:
      Aggregate* agg;
  };
  </code></pre>
  
  <p>Now I need to extend this class:</p>
  
  <pre><code>class Derived : Base {
  public:
      Derived(string name) : Base(name) {
          agg2 = new Aggregate2(name);
      }
  private:
      Aggregate2* agg2;
  };
  </code></pre>
  
  <p>What I want is when I create a <code>Base</code> object, <code>Aggregate</code> needs to be created and when I create a <code>Derived</code> object only <code>Aggregate2</code> should be created.  </p>
  
  <p>Now this is not happening because <code>Aggregate</code> its created inside the constructor which is called when I create a <code>Derived</code> object and like this <code>Aggregate</code> and <code>Aggregate2</code> would be created.  </p>
  
  <p>I could move the creation to a different method and call that after creating the object.<br>
  Is there any other elegant way to do what I want ? </p>