Callback with meber functions
-
Hi, in C++ I can implement callback functions: void (MYFUNC) (int); void func1 (int n) { //some code } void main() { MYFUNC * f = &func1; (*f)(2); //calls func1 (*f)(3); } This is simple enougth. But my question is another. How to implement the same thing on objects member function. i.e. - save object pointer and pointer to the function, then call this function for this object. I know that this is another calling conversion. I could pass object as first parameter, but on some arhitectures it's passed to stack in others to ECX register. I need more accurate code. Does anyone know how to do this? Thanks
-
Hi, in C++ I can implement callback functions: void (MYFUNC) (int); void func1 (int n) { //some code } void main() { MYFUNC * f = &func1; (*f)(2); //calls func1 (*f)(3); } This is simple enougth. But my question is another. How to implement the same thing on objects member function. i.e. - save object pointer and pointer to the function, then call this function for this object. I know that this is another calling conversion. I could pass object as first parameter, but on some arhitectures it's passed to stack in others to ECX register. I need more accurate code. Does anyone know how to do this? Thanks