#include <iostream>
class A {
public:
virtual void hoge() {
std::cout << "A" << std::endl;
}
};
class A1 : public A {
public:
void hoge() {
std::cout << "A1" << std::endl;
}
};
class A2 : public A {
public:
void hoge() {
std::cout << "A2" << std::endl;
}
};
void recieve_a(A pa) {
pa.hoge();
}
int main() {
A1 a1;
A2 a2;
recieve_a(a1); // A1 と表示させたい
recieve_a(a2); // A2 と表示させたい
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgQSB7CiAgICBwdWJsaWM6CgkJdmlydHVhbCB2b2lkIGhvZ2UoKSB7CgkJCXN0ZDo6Y291dCA8PCAiQSIgPDwgc3RkOjplbmRsOwoJCX0KfTsKCmNsYXNzIEExIDogcHVibGljIEEgewoJcHVibGljOgoJCXZvaWQgaG9nZSgpIHsKCQkJc3RkOjpjb3V0IDw8ICJBMSIgPDwgc3RkOjplbmRsOwoJCX0KfTsKCmNsYXNzIEEyIDogcHVibGljIEEgewoJcHVibGljOgoJCXZvaWQgaG9nZSgpIHsKCQkJc3RkOjpjb3V0IDw8ICJBMiIgPDwgc3RkOjplbmRsOwoJCX0KfTsKCnZvaWQgcmVjaWV2ZV9hKEEgcGEpIHsKCXBhLmhvZ2UoKTsKfQoKaW50IG1haW4oKSB7CglBMSBhMTsKCUEyIGEyOwoKCXJlY2lldmVfYShhMSk7CS8vIEExIOOBqOihqOekuuOBleOBm+OBn+OBhAoJcmVjaWV2ZV9hKGEyKTsJLy8gQTIg44Go6KGo56S644GV44Gb44Gf44GECn0=