#include <iostream>
#include <string>
class One {
public:
virtual void id(const std::string &what = "I'm class One!") const
{
std::cout << "class One says: " << what << std::endl;
}
virtual ~One()
{
}
};
struct Two: One {
void id(const std::string &what = "I'm struct Two!") const
{
std::cout << "struct Two says: " << what << std::endl;
}
};
int main()
{
One *o = new Two;
o->id();
delete o;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgoKY2xhc3MgT25lIHsKcHVibGljOgoJdmlydHVhbCB2b2lkIGlkKGNvbnN0IHN0ZDo6c3RyaW5nICZ3aGF0ID0gIkknbSBjbGFzcyBPbmUhIikgY29uc3QKCXsKCQlzdGQ6OmNvdXQgPDwgImNsYXNzIE9uZSBzYXlzOiAiIDw8IHdoYXQgPDwgc3RkOjplbmRsOwoJfQoKCXZpcnR1YWwgfk9uZSgpCgl7Cgl9Cn07CgpzdHJ1Y3QgVHdvOiBPbmUgewoJdm9pZCBpZChjb25zdCBzdGQ6OnN0cmluZyAmd2hhdCA9ICJJJ20gc3RydWN0IFR3byEiKSBjb25zdAoJewoJCXN0ZDo6Y291dCA8PCAic3RydWN0IFR3byBzYXlzOiAiIDw8IHdoYXQgPDwgc3RkOjplbmRsOwoJfQp9OwoKaW50IG1haW4oKQp7CglPbmUgKm8gPSBuZXcgVHdvOwoKCW8tPmlkKCk7CglkZWxldGUgbzsKfQ==