I have a class Myclass:
in Myclass.h file:
class{
private:
int sd;
public:
void func(int sd, short op, void *ptr);
void start();
};
in Myclass.cpp file:
void Myclass::start(){
event_set(ev, sd, EV_READ, call_func, NULL ); //this is a library API, which trigger the callback of call_func(sd, op, NULL);
}
void Myclass::func(int sd, short op, void *ptr)){
...
...
}
in start(), the event_set need a function of "void(*func)()" type as argument,but func() is of "void Myclass::(*func)()" type, so I define a new function as below:
1 2 3
void call_func(int sd, short op, void *ptr){
Myclass::func(int sd, short op, void *ptr);
}
however, I'm at a loss where to delcare and define call_func() so that the Myclass::start() can use call_func as argument and call_func() can call Myclass::func()