What will the following code print when creating an instance of class D?
struct A { A() { cout << "A"; } };
struct B : virtual A { B() { cout << "B"; } };
struct C : virtual A { C() { cout << "C"; } };
struct D : B, C { D() { cout << "D"; } };
Explanation
The constructor for A will be called only once because virtual inheritance is used.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes