How to find & remove object from a std::list ?
I'm trying to find an object in an std::list of objects, and remove it and I was going to look for the NAME of the object as a basis of comparison, something like this:
PHP Code:
class myObj
{
string name;
int A;
int B;
//......
int Z;
}
//then later in the code....
list<myObj> myList;
list<myObj>::iterator itr;
itr = find(myList.begin(),myList.end(), /*look for myObj name */ );
if (itr != myList.end())
{
itr = myList.erase(itr);
}
Question is, how do I lok for just the NAME using the find command?
Thanks for the help! :)