Question discussion

What is the output of the following C++ code involving multiple inheritance? class A { public: int x = 10; }; class B { public: int x = 20;…

550Medium DSSSB TGT Computer Science 0 replies 1 views
0
What is the output of the following C++ code involving multiple inheritance? class A { public: int x = 10; }; class B { public: int x = 20; }; class C : public A, public B { }; int main() { C obj; cout << obj.A::x << " " << obj.B::x; return 0; }
  • A10 10
  • B20 20
  • C10 20
  • DCompilation error, ambiguous
Correct answer: C

Discussion 0

Nobody has replied yet. Start the discussion!