So here\'s the situation: I\'m using C++, SDL and GLConsole in conjunction. I have a class, SDLGame
, which has the Init()
, Loop()
,
If the only interface you have is that function pointer, then you're screwed.
A member function needs a this
pointer to be called, and if you have no way of passing that, you're out of luck (I guess the std::vector
pointer is what you get passed from the library).
In other words, even though that library uses C++ containers, it's not a good C++ library, because it relies on free functions for callbacks. A good C++ library would use boost::function
or something similar, or would at the very least let you pass a void* user_data
pointer that gets passed through to your callback. If you had that, you could pass the this
pointer of your class, cast it back inside the callback, and call the appropriate member function.