title: Remove elements of a vector inside the loop
body: <p>I know that there are similar questions to this one, but I didn’t manage to find the way on my code by their aid. I want merely to delete/remove an element of a vector by checking an attribute of this element inside a loop. How can I do that? I tried the following code but I receive the vague message of error:</p>
  
  <p>'operator =' function is unavailable in 'Player’.</p>
  
  <pre><code> for (vector&lt;Player&gt;::iterator it = allPlayers.begin(); it != allPlayers.end(); it++)
   {
       if(it-&gt;getpMoney()&lt;=0) 
           it = allPlayers.erase(it);
       else 
           ++it;
   }
  </code></pre>
  
  <p>What should I do?   </p>
  
  <p><strong>Update:</strong> Do you think that the question <a href="https://stackoverflow.com/questions/2677770/vectorerase-with-pointer-member">vector::erase with pointer member</a> pertains to the same problem? Do I need hence an assignment operator? Why? </p>