title: program crashes when i use push_back() function
body: <p>I'm learning a game tutorial and I got a problem, here is the code:</p>
  
  <p><strong>in .h file</strong></p>
  
  <pre><code>std::vector&lt;GameObject*&gt; m_gameObjects;
  GameObject* a;
  </code></pre>
  
  <p><strong>in .cpp file</strong></p>
  
  <pre><code>GameObject* player = new Player;
  m_gameObjects.push_back(player);
  a=player;
  </code></pre>
  
  <p>This part of the code passes the pointer <code>player</code> to anther function that updates the screen so when I click on a play button on the screen a sprite appears</p>
  
  <p>like this</p>
  
  <pre><code>m_gameObjects[i]-&gt;update();
  </code></pre>
  
  <p>or</p>
  
  <pre><code>a-&gt;update();
  </code></pre>
  
  <p>The problem is when I use <code>m_gameObjects.push_back(player)</code> the program crashes, when I remove this line and use <code>a-&gt;update()</code> it works.</p>