title: Best way to make a child object from a list self convert into other child of same parent
body: <p>I have a list of pointers to objects from Parent</p>
  
  <pre><code>vector&lt;Parent*&gt; list;
  </code></pre>
  
  <p>then I have 2 child Classes of Parent: Child1 and Child2 that are added to the list.</p>
  
  <p>The code runs through all entities of the list and calls Execute();</p>
  
  <pre><code>for(int i = 0; i &lt; list.size(); i++)
      list[i]-&gt;Execute();
  </code></pre>
  
  <p>Execute() is a virtual function of Parent and is implemented differently in each child class. I want to make a condition <strong>inside the function of Child1::Execute()</strong> in which it is replaced by an entity of <strong>Child2</strong> at the same position in the list.</p>
  
  <p>of course I cant do this:</p>
  
  <pre><code>void Child1::Execute() {
      ...
      if(condition)
          this = new Child2();
  }    
  </code></pre>
  
  <p>But I cant figure out a good solution that does this. In the end there will be a few hundred Other Child classes from Parent that will do the same but in other conditions, so I wanted a good expandable solution.</p>
  
  <p>Thanks</p>