title: C++ child changes parent member at some point between copy constructor and ouput
body: <p>If you test the following code, it compiles and runs without issue:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class Parent
  {
  public:
      Parent(bool flag) : flag(flag) {}
      virtual void display() = 0;
  
  protected:
      bool flag;
  };
  
  class Child : public Parent
  {
  public:
      Child(bool flag) : Parent(flag) {}
      Child(const Child &amp; rhs) : Parent(rhs.flag) {}
      virtual void display() { cout &lt;&lt; flag &lt;&lt; endl; }
  };
  
  int main() 
  {
      // Set Flag to true
      Child tru(true);
      Child * storage [2]; 
      storage[0] = new Child(tru);
      storage[0]-&gt;display();
  
      // Set Flag to false
      Child * container = new Child(storage[0]);
      delete storage[0];
      storage[0] = new Child(false);
      storage[0]-&gt;display();
  
      // Set Flag to true
      storage[1] = new Child(container);
      storage[1]-&gt;display();
  
      return 0;
  }
  </code></pre>
  
  <p>However, after I plug this snippet into my program, the <strong>Child objects</strong> consistently change their <strong>bool flag</strong> to <strong>true</strong> between the time they are created with the <strong>copy constructor</strong> and the time I actually attempt to display their <strong>bool flag</strong> value. I know the change initially sticks thanks to copious amounts of <strong>cout</strong> lines calling values at every step of the way, but when my display function is called, their values all switch to true.</p>
  
  <p>I haven't been able to successfully reproduce the error, externally, but while I attempt to do so, I'm hoping someone might have an idea of what could possibly interfere with this process? Is there a common error, mistake or conflict I should be checking for in a situation like this?</p>