Sign in to follow this  

Member Function Pointers

Recommended Posts

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.
class EngineManager {
KeyboardAndMouse *Input;
Console *gameConsole;
//End EngineManager

class Console;

typedef void(Console::*keystrokecallback)(char); //doesnt work

class KeyboardAndMouse {

 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 );

Any ideas? Thanks in advance.

Share this post

Link to post
Share on other sites
Cool, thanks guys.
I may be stubborn/naive but for now I am avoiding boost.

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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this