我有:
enum Screens
{
INVENTORY,
STUFF,
CRAFTING,
GAMESCREEN,
NONE
};
typedef struct s_action
{
s_action() : _screen(NONE), _compartment(NULL){};
Screens _screen;
Compartment *_compartment;
} s_action;
std::map<Screens, std::map<Screens, void (GestionClick::*)(s_action&, s_action&)> > _correlationTable;
为了调用GestionClick的成员函数,语法是什么?
答案 0 :(得分:0)
您可以使用:
Screens a;
Screens b;
(*_correlationTable[a][b])(action1, action2);
但我强烈建议您使用using
标头中定义的std::function
声明(为了便于阅读)和std::bind
(以及可能<functional>
) (如果您使用的是C ++ 11):
using callback = std::function<void(s_action&, s_action&)>;
using screens_map = std::map<Screens, callback>;
std::map<Screens, std::map<Screens, screens_map> _correlationTable;