#include <iostream>
using namespace std;
class A
{
int x;
public:
A() : x(0) {cout<<"Конструктор А 1"<<endl;}
A(int a) : x(a) {cout<<"Конструктор А 2"<<endl;}
int func() const {return x;}
};
class B : public virtual A
{
int x;
public:
B(int a) : A(a*a), x(a) {cout<<"Конструктор B"<<endl;}
int func() const {return x;}
};
class C : public virtual A
{
int x;
public:
C(int a) : A(a*a), x(a) {cout<<"Конструктор C"<<endl;}
int func() const {return x;}
};
class D : public B, public C
{
int x;
public:
D(int a, int b) : B(a), C(b), x(a+b) {cout<<"Конструктор D"<<endl;}
int func() const {return x;}
};
int main()
{
D a(12,78);
cout<<"D::x = "<<a.func()<<endl;
cout<<"B::x = "<<a.B::func()<<endl;
cout<<"C::x = "<<a.C::func()<<endl;
cout<<"А::x = "<<a.A::func()<<endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgQQp7CglpbnQgeDsKcHVibGljOgpBKCkgOiB4KDApIHtjb3V0PDwi0JrQvtC90YHRgtGA0YPQutGC0L7RgCDQkCAxIjw8ZW5kbDt9CkEoaW50IGEpIDogeChhKSB7Y291dDw8ItCa0L7QvdGB0YLRgNGD0LrRgtC+0YAg0JAgMiI8PGVuZGw7fQppbnQgZnVuYygpIGNvbnN0IHtyZXR1cm4geDt9Cn07CmNsYXNzIEIgOiBwdWJsaWMgdmlydHVhbCBBCnsKCWludCB4OwpwdWJsaWM6CkIoaW50IGEpIDogQShhKmEpLCB4KGEpIHtjb3V0PDwi0JrQvtC90YHRgtGA0YPQutGC0L7RgCBCIjw8ZW5kbDt9CmludCBmdW5jKCkgY29uc3Qge3JldHVybiB4O30KfTsKY2xhc3MgQyA6IHB1YmxpYyB2aXJ0dWFsIEEKewoJaW50IHg7CnB1YmxpYzoKQyhpbnQgYSkgOiBBKGEqYSksIHgoYSkge2NvdXQ8PCLQmtC+0L3RgdGC0YDRg9C60YLQvtGAIEMiPDxlbmRsO30KaW50IG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