#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= {make_pair("func_1",new func_1()),
make_pair("func_2",new func_2())
};
func["func_1"]->func();
func["func_2"]->func();
delete func["func_1"];
delete func["func_2"];
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8bWFwPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNsYXNzIGhlYWRlcgp7CnB1YmxpYzoKICAgIHZpcnR1YWwgdm9pZCBmdW5jKHZvaWQpPTA7Cn07CgpjbGFzcyBmdW5jXzEgOiBwdWJsaWMgaGVhZGVyCnsKcHVibGljOgogICAgdmlydHVhbCB2b2lkIGZ1bmModm9pZCkKICAgIHsKICAgICAgICBjb3V0PDwiZnVuY18xIjw8ZW5kbDsKICAgIH0KfTsKCmNsYXNzIGZ1bmNfMiA6IHB1YmxpYyBoZWFkZXIKewpwdWJsaWM6CiAgICB2aXJ0dWFsIHZvaWQgZnVuYyh2b2lkKQogICAgewogICAgICAgIGNvdXQ8PCJmdW5jXzIiPDxlbmRsOwogICAgfQp9OwoKaW50IG1haW4odm9pZCkKewogICAgbWFwPHN0cmluZyxoZWFkZXIqPiBmdW5jPSB7bWFrZV9wYWlyKCJmdW5jXzEiLG5ldyBmdW5jXzEoKSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYWtlX3BhaXIoImZ1bmNfMiIsbmV3IGZ1bmNfMigpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwoKICAgIGZ1bmNbImZ1bmNfMSJdLT5mdW5jKCk7CiAgICBmdW5jWyJmdW5jXzIiXS0+ZnVuYygpOwoKICAgIGRlbGV0ZSBmdW5jWyJmdW5jXzEiXTsKICAgIGRlbGV0ZSBmdW5jWyJmdW5jXzIiXTsKCiAgICByZXR1cm4gMDsKfQo=