-2

I have :

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;

What is the syntax in order to call a member function of GestionClick ?

Bob
  • 589
  • 1
  • 11
  • 25
  • 1
    `(gc.*_correlationTable[_screen1][_screen2])(s_action1, s_action2)` – David G Dec 23 '13 at 18:00
  • I wouldn't call this a syntax question, it's more a basic understanding of accessing maps, and calling functions. Check http://www.cplusplus.com/reference/map/map/operator[]/ and http://stackoverflow.com/questions/1043034/what-does-void-mean-in-c-c-and-c – tinkertime Dec 23 '13 at 18:11

1 Answers1

0

You can use:

Screens a;
Screens b;
(*_correlationTable[a][b])(action1, action2);

But I'm highly going to suggest that you use some using declarations (for readability) and std::function (and possibly std::bind) defined in the <functional> header instead (if you are using 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;
Shoe
  • 74,840
  • 36
  • 166
  • 272