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