There is this code:
#include <iostream> class Bazowa { int x; public: Bazowa() : x(55){} Bazowa(int x_) : x(x_) {} void fun() { std::cout << x << "fun\n"; } }; class Pochodna1 : virtual public Bazowa { public: Pochodna1() : Bazowa(101) {} }; class Pochodna2 : virtual public Bazowa { public: Pochodna2() : Bazowa(103) {} }; class SuperPochodna : public Pochodna1, public Pochodna2 { public: SuperPochodna() : {} }; int main() { SuperPochodna sp; sp.fun(); // prints 55fun return 0; }
After executing this program, it will print “55fun”. What happened to the design challenges in the Pochodna1 and Pochodna2 classes - are they ignored? Why is the 'x' member of the Bazowa class set to '55' but not '101' or '103'?
scdmb source share