I am aware that there are questions like this one, but I was unable to use them to help me decipher my code.
I just want to remove or delete one element from a vector by running a loop over its property.
How can I go about doing that?
I tried the following code, but I got an ambiguous error message:
'operator =' function is unavailable in 'Player’.
for (vector<Player>::iterator it = allPlayers.begin(); it != allPlayers.end(); it++)
{
if(it->getpMoney()<=0)
it = allPlayers.erase(it);
else
++it;
}
What should I do?