title: How do vectors clean up after themselves? (Or do they?)
body: <p>I'm making a game that simulates skeet shooting for my programming class.
  The main <code>Game</code> class contains <code>std::vector&lt;Bullet&gt; bullets</code>, where <code>Bullet</code> is my class. It contains only members of concrete types, and overrides a base <code>Drawable</code> class to draw and update itself. It does not redefine any operators. At every frame, <code>bullets</code> is looped through, and each bullet is updated and drawn.</p>
  
  <p>When the user presses a key, I'm adding a <code>Bullet</code> to <code>bullets</code> like so:</p>
  
  <p>In Game :: handleInput:</p>
  
  <pre><code>if (ui.isSpaceBar())
  {
     Bullet newBullet = rifle.fire();
     addBullet(newBullet);
  }
  </code></pre>
  
  <p><code>rifle.fire</code> returns a <code>Bullet</code> like so:</p>
  
  <pre><code>Bullet Rifle :: fire()
  {
     ... calculation of position and velocity...
     return Bullet(...position and velocity values...);
  }
  </code></pre>
  
  <p>and <code>addBullet</code> looks like this:</p>
  
  <pre><code>void addBullet(const Bullet &amp; newBullet)
  {
     bool assigned = false;
     for (int i = 0; i &lt; bullets.size(); i++)
     {
        // If the i'th bullet is off-screen or hit something ...
        if (bullets[i].isDead())
        {
           // ... then overwrite it with the new bullet,
           // instead of using push_back, to avoid constantly
           // increasing the size of the vector
           bullets[i] = newBullet;
           assigned = true;
           break;
        }
     }
  
     if (!assigned)
        bullets.push_back(newBullet);
  }
  </code></pre>
  
  <p>My question is about the line <code>bullets[i] = newBullet;</code>. Do I need to <code>delete</code> anything before overwriting the value in the vector using the indexer? If I understand correctly, using values instead of pointers (<code>Bullet</code> instead of <code>Bullet *</code>, and <code>return Bullet(...)</code> instead of <code>return new Bullet(...)</code>) means I don't ever have to call <code>delete</code>, and the <code>Bullet</code> instances are destroyed automatically when they go out of scope, which will be when the vector goes out of scope. Is that right? If so, does using the vector's indexer operator <code>delete</code> the old value (the "dead" bullet, in this case)? If not, what am I missing? And should I be using pointers instead of values?</p>