Code: Show/Hide #include <map> using std::map; class UserData { map<long, void (UserData::*)(CORE_DATA *cd)> *timersBot; /* timersBot is a pointer to an STL map<> * that has an integer as the key, * and a pointer-to-a member function of UserData-class as the value */ } |
Code: Show/Hide ... map<long, void (UserData::*)(CORE_DATA *cd)>::iterator iter = /* assume the iterator is valid */ CORE_DATA *cd = /* assume this is valid */ /* What I've tried: */ (iter->*second)(cd); // compiler error " 'second' was not declared in this scope" (*(iter->second))(cd); // compiler error " invalid use of `unary *' on pointer to member" UserData *ud = /* assume this is valid */ ud->*(iterBotT->second)(cd); // compiler error " must use .* or ->* to call pointer-to-member function ..... /* * How can invoke the function from the pointer-to-function * that's stored in iter->second ? */ (ud->*iterBotT->second)(cd); // IT COMPILES but why? ... |