title: How to avoid memory leaks when using a vector of pointers to dynamically allocated objects in C++?
body: <p>I'm using a vector of pointers to objects. These objects are derived from a base class, and are being dynamically allocated and stored.</p>
  
  <p>For example, I have something like:</p>
  
  <pre><code>vector&lt;Enemy*&gt; Enemies;
  </code></pre>
  
  <p>and I'll be deriving from the Enemy class and then dynamically allocating memory for the derived class, like this:</p>
  
  <pre><code>enemies.push_back(new Monster());
  </code></pre>
  
  <p>What are things I need to be aware of to avoid memory leaks and other problems?</p>