#include <iostream>
class A {
public:
A(bool call) __attribute__((optnone)) {
std::cout << "A() is constructed (this = " << static_cast<void*>(this) << ")\n";
hello();
}
~A() {
std::cout << "A() is destructed (this = " << static_cast<void*>(this) << ")\n";
}
virtual void hello() = 0;
};
void A::hello() {
std::cout << "Hello from A! (this = " << static_cast<void*>(this) << ")\n";
}
class B : public A {
public:
B(bool call ) : A(call) {
std::cout << "B() is constructed (this = " << static_cast<void*>(this) << ")\n";
hello();
}
~B() {
std::cout << "B() is destructed (this = " << static_cast<void*>(this) << ")\n";
}
virtual void hello();
};
void B::hello() {
std::cout << "Hello from B! (this = " << static_cast<void*>(this) << ")\n";
}
int main() {
//B not_call(false);
B call(true);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgQSB7CiBwdWJsaWM6CiAgIEEoYm9vbCBjYWxsKSBfX2F0dHJpYnV0ZV9fKChvcHRub25lKSkgewogICAJc3RkOjpjb3V0IDw8ICJBKCkgaXMgY29uc3RydWN0ZWQgKHRoaXMgPSAiIDw8IHN0YXRpY19jYXN0PHZvaWQqPih0aGlzKSA8PCAiKVxuIjsKICAgCWhlbGxvKCk7CiAgIH0KICAgfkEoKSB7CiAgIAlzdGQ6OmNvdXQgPDwgIkEoKSBpcyBkZXN0cnVjdGVkICh0aGlzID0gIiA8PCBzdGF0aWNfY2FzdDx2b2lkKj4odGhpcykgPDwgIilcbiI7CiAgIH0KICAgdmlydHVhbCB2b2lkIGhlbGxvKCkgPSAwOwp9OwoKdm9pZCBBOjpoZWxsbygpIHsKICBzdGQ6OmNvdXQgPDwgIkhlbGxvIGZyb20gQSEgKHRoaXMgPSAiIDw8IHN0YXRpY19jYXN0PHZvaWQqPih0aGlzKSA8PCAiKVxuIjsKfQoKY2xhc3MgQiA6IHB1YmxpYyBBIHsKIHB1YmxpYzoKICAgQihib29sIGNhbGwgKSA6IEEoY2FsbCkgewogICAJc3RkOjpjb3V0IDw8ICJCKCkgaXMgY29uc3RydWN0ZWQgKHRoaXMg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