#include <iostream>
class B
{
protected:
int x;
protected:
B(int x) : x{x}{std::cout << x << std::endl;}
};
class B1 : virtual public B
{
protected:
B1() : B(0){}
};
class B2 : virtual public B
{
protected:
B2() : B(10){}
};
class D : public B1, public B2
{
public:
D() : B{99}, B1{}, B2{} {}
void print() {std::cout << "Final: " << x << std::endl;}
};
int main() {
D d;
d.print();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgQgp7CnByb3RlY3RlZDoKICAgIGludCB4OwoKcHJvdGVjdGVkOgoKICAgIEIoaW50IHgpIDogeHt4fXtzdGQ6OmNvdXQgPDwgeCA8PCBzdGQ6OmVuZGw7fQp9OwoKY2xhc3MgQjEgOiB2aXJ0dWFsIHB1YmxpYyBCCnsKcHJvdGVjdGVkOgoKICAgIEIxKCkgOiBCKDApe30KfTsKCmNsYXNzIEIyIDogdmlydHVhbCBwdWJsaWMgQgp7CnByb3RlY3RlZDoKCiAgICBCMigpIDogQigxMCl7fQp9OwoKY2xhc3MgRCA6IHB1YmxpYyBCMSwgcHVibGljIEIyCnsKcHVibGljOgoKICAgIEQoKSA6IEJ7OTl9LCBCMXt9LCBCMnt9IHt9CiAgICB2b2lkIHByaW50KCkge3N0ZDo6Y291dCA8PCAiRmluYWw6ICIgPDwgeCA8PCBzdGQ6OmVuZGw7fQp9OwoKaW50IG1haW4oKSB7CglEIGQ7CglkLnByaW50KCk7CglyZXR1cm4gMDsKfQ==
prog.cpp: In constructor ‘D::D()’:
prog.cpp:17:5: error: ‘B1::B1()’ is protected
B1() : B(0){}
^
prog.cpp:31:27: error: within this context
D() : B{99}, B1{}, B2{} {}
^
prog.cpp:24:5: error: ‘B2::B2()’ is protected
B2() : B(10){}
^
prog.cpp:31:27: error: within this context
D() : B{99}, B1{}, B2{} {}
^