I would like to know how to remove an object from a list base on a condition.
After researching, this is what I got, but it still doesn't work!
So I would like to know how to use remove_if
with erase.
Class A
{
public:
A(int x,int y);
int x;
int y;
};
int main()
{
list<A> listA;
A lista1(123,32);
listA.push_back(lista1);
A lista2(3123,1233);
listA.push_back(lista2);
A lista3(123,4123);
listA.push_back(lista3);
//HERE HOW TO REMOVE LIST if x = 123?
listA.erase(remove_if(listA.begin(),listA.end(),/*REMOVE CRITERIA*/);
}