lundi 26 décembre 2016

how to provide a function for a c++ class that can call a member function by its name

class f
{
   public:
        run(std::string method,std::string params)
        {
            ...//call foo1 or foo2 with params by "method"
        }

        foo1(std::string a);
        foo2(std::string a);

}

I'm trying to make a map<std::string,std::function<void(std::string)>> to implement it,but there is a error reported since the non-static member function needs a pointer to an instance.I'm not going to use function pointer like typdef f xxx,I preper to make a map between funcname and function.

Aucun commentaire:

Enregistrer un commentaire