#include <iostream>
using namespace std;
class A {
public:
A() {
log("Constructor A");
}
~A() {
log("Destructor A");
}
virtual void log(const char* message) {
std::cout << "Log from A! (" << message << ")\n";
}
virtual void do_something() {
log("Do something");
}
};
class B : public A{
public:
B() {
log("Constructor B");
}
~B() {
log("Destructor B");
}
virtual void log(const char* message) {
std::cout << "Log from B! (" << message << ")\n";
}
};
int main() {
B b;
b.do_something();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgQSB7CiBwdWJsaWM6CiAgIEEoKSB7CiAgIAkgbG9nKCJDb25zdHJ1Y3RvciBBIik7CiAgIH0KICAgfkEoKSB7CiAgIAkgbG9nKCJEZXN0cnVjdG9yIEEiKTsKICAgfQogICB2aXJ0dWFsIHZvaWQgbG9nKGNvbnN0IGNoYXIqIG1lc3NhZ2UpIHsKICAgCXN0ZDo6Y291dCA8PCAiTG9nIGZyb20gQSEgKCIgPDwgbWVzc2FnZSA8PCAiKVxuIjsKICAgfQogICB2aXJ0dWFsIHZvaWQgZG9fc29tZXRoaW5nKCkgewogICAJIGxvZygiRG8gc29tZXRoaW5nIik7CiAgIH0KfTsKCmNsYXNzIEIgOiBwdWJsaWMgQXsKIHB1YmxpYzoKICAgQigpIHsKICAgCSBsb2coIkNvbnN0cnVjdG9yIEIiKTsKICAgfQogICB+QigpIHsKICAgCSBsb2coIkRlc3RydWN0b3IgQiIpOwogICB9CiAgIHZpcnR1YWwgdm9pZCBsb2coY29uc3QgY2hhciogbWVzc2FnZSkgewogICAJc3RkOjpjb3V0IDw8ICJMb2cgZnJvbSBCISAoIiA8PCBtZXNzYWdlIDw8ICIpXG4iOwogICB9Cn07CgppbnQgbWFpbigpIHsKCUIgYjsKCWIuZG9fc29tZXRoaW5nKCk7Cn0=