//EngineManager.h
class EngineManager {
private:
KeyboardAndMouse *Input;
Console *gameConsole;
};
//End EngineManager
//Input.h
class Console;
typedef void(Console::*keystrokecallback)(char); //doesnt work
class KeyboardAndMouse {
public:
vector <keystrokecallback> keyCallBackList;
};
//end input.h
//console class
class Console{
void keyboardReactor(char c);
}
//end console class
//EngineManager.cpp calls this guy
Input->keyCallbackList.push_back( &Console::keyboardReactor );
Member Function Pointers
ugh... im trying to wrap my head around this. Basically my engine had extern items that, for the sake of architecture, were brought into their respective classes. The problem is... some of those extern items were function pointers... thus making them.. member function pointers.
And now another class is trying to dereference that member function pointer. What was a nice clean line of code now is broken.. and i am trying to figure out how to fix it...
here is the issue in pseudo code.
Any ideas?
Thanks in advance.
Check out boost::function and boost::bind. They will let you bind a member function pointer to an instance, and then call it like a free function. The sample code has more details, plus this has come up many times before in the forums so you can Google for other threads.
Cool, thanks guys.
I may be stubborn/naive but for now I am avoiding boost.
I think i see what my problem is ... i need to have the object instance and use that macro-ish thing in the faq
#define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember))
to make it readable
the syntax on the right is what i dont have.
I may be stubborn/naive but for now I am avoiding boost.
Quote:Original post by Driv3MeFar
Read me.
Edit: link fixed.
I think i see what my problem is ... i need to have the object instance and use that macro-ish thing in the faq
#define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember))
to make it readable
the syntax on the right is what i dont have.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement