Answer the question
In order to leave comments, you need to log in
How to put pointers to class functions in std::map?
Let's say I have a class
class Foo
{
public:
static Foo *fromFoo();
static Foo *fromBar();
};
if(str == "foo") {} ....
Answer the question
In order to leave comments, you need to log in
Static methods are regular functions.
typedef (Foo*) (*func)();
std::map<std::string, func> map;
map["fromFoo"] = &Foo::fromFoo;
map["fromBar"] = &Foo::fromBar;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question