title: C++ - Deleting a vector element that is referenced by a pointer
body: <p>Well, I don't know if it is possible, but the thing would be:</p>
  
  <pre><code>struct stPiece
  {
    /* some stuff */
    stPiece *mother; // pointer to the piece that created this one
  };
  
  vector&lt;stPiece&gt; pieces;
  </code></pre>
  
  <p>Is it possible to erase the piece referenced by 'mother' from pieces, having just that pointer as a reference? How?</p>
  
  <p>Would it mess with the other references? (i.e. if it is not the last element in the vector, by shifting the next elements to other memory positions, while the other '*mothers' remain constant). Of course, I assuming that all the child pieces will be deleted (so I won't need to update any pointer that goes to the same mother).</p>
  
  <p>Thanks!</p>