 <p>Get rid of your loop. <code>std::find()</code> (and <code>std::find_if()</code>) does the necessary looping for you.</p> <p><code>std::find()</code> (and <code>std::find_if()</code>) returns an iterator to the element if found, or the specified <code>last</code> iterator if not found. If the element is found, pass the returned iterator to the vector's <code>erase()</code> method to remove the element.</p> <p>Since you are storing pointers in your vector, you cannot use <code>std::find()</code> to search by a <code>std::string</code> value. You need to use <code>std::find_if()</code> instead.</p> <p>Try this:</p> <pre><code>struct isID { const std::string &amp;m_id; isID(const std::string &amp;id) : m_id(id) {} bool operator()(const member *m) const { return (m-&gt;id == m_id); } }; </code></pre> <p></p> <pre><code>std::string id = ...; std::vector&lt;member*&gt;::iterator iter = std::find_if(memb.begin(), memb.end(), isID(id)); if (iter != memb.end()) { // since you are storing pointers in the vector, you // need to free the object being pointed at, if noone // else owns it... //delete *iter; memb.erase(iter); } </code></pre> <p>Or, if you are using C++11 or later:</p> <pre><code>std::string id = ...; auto iter = std::find_if(memb.begin(), memb.end(), [id](const member* m) { return (m-&gt;id == id); } ); if (iter != memb.end()) { // since you are storing pointers in the vector, you // need to free the object being pointed at, if noone // else owns it... //delete *iter; memb.erase(iter); } </code></pre> <p>In the latter case, if the vector is intended to own the objects, you can store <code>std::unique_ptr</code> objects in the vector to automatically free the <code>member</code> objects for you:</p> <pre><code>std::vector&lt;std::unique_ptr&lt;member&gt;&gt; memb; ... std::unique_ptr&lt;member&gt; m(new member); // or: std::unique_ptr&lt;member&gt; m = std::make_unique_ptr&lt;member&gt;(); memb.push_back(std::move(m)); // or: memb.push_back(std::unique_ptr&lt;member&gt;(new member)); // or: memb.push_back(std::make_unique&lt;member&gt;()); // or: memb.emplace_back(new member); ... if (iter != memb.end()) { // std::unique_ptr will free the object automatically // when the std::unique_ptr itself is destroyed... memb.erase(iter); } </code></pre>