Question discussion

What is the output of the following C++ code? class Base { public: virtual void show() { cout

548Medium DSSSB TGT Computer Science 0 replies 1 views
0
What is the output of the following C++ code? class Base { public: virtual void show() { cout << "Base"; } }; class Derived : public Base { public: void show() override { cout << "Derived"; } }; int main() { Base *b = new Derived(); b->show(); return 0; }
  • ABase
  • BDerived
  • CCompilation error
  • DBaseDerived
Correct answer: B

Discussion 0

Nobody has replied yet. Start the discussion!