Question

Consider the following C++ code:     class Base {     public:         void show() { std::cout << "Base::show" << std::endl; }     };     class Derived : public Base {     public:         void show() { std::cout << "Derived::show" << std::endl; }     };     int main() {         Base b;         Derived d;         Base* ptr = &d;         ptr->show();         return 0;     }     What will be the output of this code?

A Base::show
B Derived::show
C Compilation Error
D Runtime Error
E Nothing, the program will not execute.
Practice Next

Hey! Ask a query

🎓
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
  • 200 Questions with Detailed Solutions
  • Section-wise Coverage (GA, English, Quant & Reasoning)