Top.Mail.Ru
The C++ Community's Journal -- Day
? ?
The C++ Community's Journal -- Day [entries|friends|calendar]
The C++ Community

[ userinfo | livejournal userinfo ]
[ calendar | livejournal calendar ]

Member function pointers to member functions [30 Dec 2003|11:39pm]
Is there any way to have a member function pointer point to a member function of the same class?
I'd imagine that there was, but my every attempt is met with compile errors and Google only ever seems to return things to do with pointers to member functions of an instance of a class...

As an example of what I mean:

I have a function pointer that's a member of a class:

void (GameState::*current_drawer)();

and I want to point it at a member function of that class

current_drawer = DrawTitle;

but I can't seem to call it once I've done that. Every time I use it as I would normally:

(*current_drawer)()

I get the compile errors

* : illegal on operands of type 'void (__thiscall GameState::*)(void)
term does not evaluate to a function taking 0 arguments


Alternatively, if I remove the * and just call it as I would a standard function

current_drawer()

I get just the latter error.

Does anyone know if/how this can be done?
6 comments|post comment

navigation
[ viewing | December 30th, 2003 ]
[ go | previous day|next day ]
Image