hi my code looks something like this
class State
{
public:
State * create(void);
};
typedef State * (*createFunc)(void);
class Registery
{
private:
static std::map<std::string, createFunc> registery()
public:
static void register_func(std::string key, createFunc func)
{
registery[key] = func;
}
static State * create(std::string key)
{
return registery[key]();
}
};
int main()
{
Registery::register_func("state", State::create);
State * s = Registery::create("state");
}
the problem is that when I try to compile it I receive this error:
error: no match for ‘operator[]’ (operand types are ‘std::map< std::basic_string< char>, State* (*)()>()’ and ‘std::string {aka std::basic_string< char>}’)
as far as I can see the types match so I don't really understand why I have an error
Aucun commentaire:
Enregistrer un commentaire