Is there possibility in c++ to call function which name was given as a string arg in another function. for example:
void func1()
{
// do something
}
void func2()
{
// do something
}
int main()
{
call("func1");
call("func2");
}
You can create a std::map of std::functionC++11
std::map<std::string, std::function<void()> > call;
call["func1"] = func1 ;
call["func2"] = func2 ;
Then,
call["func1"]( ) ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With