Deleting an object in a vector
<p>I am trying to delete an element in a vector of Objects. The vector is filled with instances of <code>Object</code> and at some point, I want to remove a certain element in a vector not by index, but by the element itself.</p>

<p>A simple example would be:</p>

<pre><code>std::vector&lt; string &gt; strVector;
strVector.push_back( "abc" );
strVector.push_back( "def" );
strVector.push_back( "ghi" ); // So strVector should contain "abc", "def", and "ghi"
</code></pre>

<p>How do I remove "ghi" from that vector? Note that I don't know where "ghi" is in that vector.</p>

<pre><code>// Something like this. Assume strVector = [ "abc", "cba", "ccb", "bac", "aaa" ]
strVector.removeElement( "ccb" );
</code></pre>

<p>A more relevant example to what I a working on:</p>

<pre><code>class MyClass {
   std::vector&lt; Object &gt; myObjVector;
   void main( ARGS ) {
      for ( int i = 0; i &lt; 10; i++ ) {
         Object myObject = Object( );
         myObjVector.push_back( myObject );
      }

      int j = getANumber( ); // j could be any number within the size of the vector
      Object myOtherObject = myObjectVector.at( j );

      // How do I erase myOtherObject (which is an object inside the vector) ?
      removeFromVector( myOtherObject );
   }
}
</code></pre>

<p>I hope the question's clear. Thanks in advance.</p>

<p><em>EDIT</em>: I figured it out, thanks to all those who answered. The trick was to give the class something unique that identifies it (like a name or a tag, as long as they are guaranteed to be unique) then use the <a href="http://en.wikipedia.org/wiki/Erase-remove_idiom" rel="nofollow">erase-remove idiom</a> to remove the object from the array.</p>
