I was wondering if there was a way that I could make a map(in C++) return a func. This is my code now and it doesn't work, I get a compiler error.
#include <map>
#include <iostream>
#include <string>
using namespace std;
map<string, void()> commands;
void method()
{
cout << "IT WORKED!";
}
void Program::Run()
{
commands["a"]();
}
Program::Program()
{
commands["a"] = method;
Run();
}
Any bit of advice would be awesome! Thank you in advance.
std::map<std::string, std::function<void()>>