#include <iostream>
class A {
public:
A() : x(-1) {}
A(int num) : x(num) {}
int getX() { return x; }
private:
const int x;
};
class B : public A {
public:
B() : A() {}
B(int num) : A(num) {}
};
class C : public B {
public:
C(int num) : B() {}
};
int main() {
B b(2);
C c(5);
//should print 2
std::cout << "b: " << b.getX() << std::endl;
//should print -1
std::cout << "c: " << c.getX() << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgQSB7CnB1YmxpYzoKICAgIEEoKSA6IHgoLTEpIHt9CiAgICBBKGludCBudW0pIDogeChudW0pIHt9CiAgICBpbnQgZ2V0WCgpIHsgcmV0dXJuIHg7IH0KcHJpdmF0ZToKCWNvbnN0IGludCB4Owp9OwoKY2xhc3MgQiA6IHB1YmxpYyBBIHsKcHVibGljOgogICAgQigpIDogQSgpIHt9CglCKGludCBudW0pIDogQShudW0pIHt9Cn07CgpjbGFzcyBDIDogcHVibGljIEIgewpwdWJsaWM6CglDKGludCBudW0pIDogQigpIHt9Cn07CgppbnQgbWFpbigpIHsKCUIgYigyKTsKCUMgYyg1KTsKCQoJLy9zaG91bGQgcHJpbnQgMgoJc3RkOjpjb3V0IDw8ICJiOiAiIDw8IGIuZ2V0WCgpIDw8IHN0ZDo6ZW5kbDsKCQoJLy9zaG91bGQgcHJpbnQgLTEKCXN0ZDo6Y291dCA8PCAiYzogIiA8PCBjLmdldFgoKSA8PCBzdGQ6OmVuZGw7CgkKCXJldHVybiAwOwp9