#include <iostream>
#include <string>
#include <map>
using namespace std;
class header
{
public:
virtual void func(void)=0;
};
class func_1 : public header
{
public:
virtual void func(void)
{
cout<<"func_1"<<endl;
}
};
class func_2 : public header
{
public:
virtual void func(void)
{
cout<<"func_2"<<endl;
}
};
int main(void)
{
map<string, header *> func;
func["func_1"] = new func_1();
func["func_2"] = new func_2();
func["func_1"]->func();
func["func_2"]->func();
// 理論上要把 new 出來的東西給 delete 掉
// 讓我偷懶一下吧
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8bWFwPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNsYXNzIGhlYWRlcgp7CnB1YmxpYzoKICAgIHZpcnR1YWwgdm9pZCBmdW5jKHZvaWQpPTA7Cn07CgpjbGFzcyBmdW5jXzEgOiBwdWJsaWMgaGVhZGVyCnsKcHVibGljOgogICAgdmlydHVhbCB2b2lkIGZ1bmModm9pZCkKICAgIHsKICAgICAgICBjb3V0PDwiZnVuY18xIjw8ZW5kbDsKICAgIH0KfTsKCmNsYXNzIGZ1bmNfMiA6IHB1YmxpYyBoZWFkZXIKewpwdWJsaWM6CiAgICB2aXJ0dWFsIHZvaWQgZnVuYyh2b2lkKQogICAgewogICAgICAgIGNvdXQ8PCJmdW5jXzIiPDxlbmRsOwogICAgfQp9OwoKaW50IG1haW4odm9pZCkKewogICAgbWFwPHN0cmluZywgaGVhZGVyICo+IGZ1bmM7CiAgICBmdW5jWyJmdW5jXzEiXSA9IG5ldyBmdW5jXzEoKTsKICAgIGZ1bmNbImZ1bmNfMiJdID0gbmV3IGZ1bmNfMigpOwoKICAgIGZ1bmNbImZ1bmNfMSJdLT5mdW5jKCk7CiAgICBmdW5jWyJmdW5jXzIiXS0+ZnVuYygpOwoKICAgIC8vIOeQhuirluS4iuimgeaKiiBuZXcg5Ye65L6G55qE5p2x6KW/57WmIGRlbGV0ZSDmjokKICAgIC8vIOiuk+aIkeWBt+aHtuS4gOS4i+WQpwoKICAgIHJldHVybiAwOwp9Cg==