Hi.
Question: What's the best way to wrap an API call that receives a callback function pointer in a C++ class.
I'm asking because:
1. Callback functions have to be static.
2. They need to access the members of the class in which they reside. In order for them to do that, these have to be static as well...
I tried taking the callbacks outside the class definition, but that's plain ugly. It worked though - But I had to pass them a pointer to my class, which meant they could only access the public members...
Is there a smarter way of solving this?
Thanks,
Assaf.
Most windows callback function are passed a VOID * pointer that is specified when the callback is "registered". You can use this VOID * to specify a pointer to an object whose member function is called. The static callback function can convert this VOID * pointer back to a pointer to an object and then call the member function.