I want to create a custom event handler into a class and pass function of another class.
class EventArgs
{
};
class one
{
public:
typedef void(EventHandler)(EventArgs* e);
void RegisterFunction(EventHandler* f);
private:
list<EventHandler*>function_list;
};
class two
{
public:
two();
private:
void FunctionEvent(EventArgs* e);
};
two::two()
{
one on;
on.RegisterFunction(&FunctionEvent);
}
The error code is: no matching function for call to ‘one::RegisterFunction(void (two::) EventArgs))’ on.RegisterFunction(&FunctionEvent);
if the FunctionEvent() it does not belong at class two like this work:
void FunctionEvent(EventArgs* e)
{
}
int main()
{
one on;
on.RegisterFunction(&FunctionEvent);
}
what is the difference?