title: Different initialization of base class attribute
body: <p>Consider a base class that has an attribute</p>
  
  <pre><code>class Base 
  {
    protected:
  
    AttributeBase * elementPtr;
    ...
  };
  </code></pre>
  
  <p>And a derived class</p>
  
  <pre><code>class Derived : public Base
  {
    ...
  };
  </code></pre>
  
  <p>Also I have a class <code>AttributeDerived</code> which derives from <code>AttributeBase</code></p>
  
  <p>When I create an object of the class <code>Base</code> I would like <code>elementPtr</code> to be initialized in this way:</p>
  
  <pre><code>elementPtr = new AttributeBase()
  </code></pre>
  
  <p>But when I create an object of the class <code>Derived</code> I would like <code>elementPtr</code> to be initialized in this way:</p>
  
  <pre><code>elementPtr = new AttributeDerived()
  </code></pre>
  
  <p>What is the cleanest way to do that?</p>