#include <iostream> #include <thread> #include <chrono> #include <mutex> #include <deque> #include <map> #include <condition_variable> using namespace std; typedef void(*fun)(char *) ; class regist { public: regist() {}; void add(std::string key, fun f) { m[key] = f; }; fun run(std::string key) { return m[key]; } private: std::map<std::string, fun > m; }; void a(char *a) { cout << "a:" << a << endl; } void b(char *a) { cout <<"b:"<< a << endl; } int main() { regist reg; reg.add("a",a); reg.add("b", a); reg.run("b")((char *)"aaaa"); reg.run("a")((char *)"bbbbb"); return 0; }