Pointer to Member Operator?
-
The amazing yet ellusive ->* operator appears to require an object of a known type. Suppose you want to call a member function of an arbitrary object? For example, in the creation of a service, I designed an interface to allow consumers to pass in a "this" pointer and their callback function. What's the recommended way to dish up the program counter to them when all I have are these two items? void *pThis; typedef BOOL (CALLBACK * LPFGETMESSAGE)(IN EMS_HANDLE hSentMessage, IN CString &Body, IN BOOL bSuccess); I have no way to find out what type of object "pThis" is, nor do I WANT to know. Best of, James Prevallet http://www.mp3.com/JamesPrevallet
-
The amazing yet ellusive ->* operator appears to require an object of a known type. Suppose you want to call a member function of an arbitrary object? For example, in the creation of a service, I designed an interface to allow consumers to pass in a "this" pointer and their callback function. What's the recommended way to dish up the program counter to them when all I have are these two items? void *pThis; typedef BOOL (CALLBACK * LPFGETMESSAGE)(IN EMS_HANDLE hSentMessage, IN CString &Body, IN BOOL bSuccess); I have no way to find out what type of object "pThis" is, nor do I WANT to know. Best of, James Prevallet http://www.mp3.com/JamesPrevallet
You can make a generic baseclass, with a virtual callback function, that your costumers have to inherit from. Then, instead of void *pThis; you can say MyBaseClass *pThis; pThis->CallBackFunction(); - Anders Money talks, but all mine ever says is "Goodbye!"