0

I apologise if that is a mundane question, but I struggle to find a clear-cut answer to it. I have a list of user defined objects which are called Events, which is in turn a part of an event simulation. I would like to remove objects from the list which have a specific value of one of their members (type), which is provided dynamically by the user. The relevant code I got so far (which works with a constant, after all references to "a" are removed):

// The Event class from a header file

class Event
{
public:
    double tte;
    int type, code;
};

// Source file

bool destroy(const Event & check, int a)
{
    return check.type == a;
}

int main()
{
list<Event> event_list;
// events are being added to the list
cin >> a;
event_list.remove_if(destroy(a));

I gather that the problem is the fact that the variable "a" cannot be passed using the remove_if function; it is supposed to have only one argument, not two. Would you have any advice on how to deal with this issue?

Thank you in advance!

MagicM
  • 37
  • 7

0 Answers0