Question OOP-POLY-0037
EasyWhat is the output of this code?
#include <iostream>
using namespace std;
class A {
public:
virtual void show() { cout << "A"; }
virtual ~A() {}
};
class B : public A {
public:
void show() override { cout << "B"; }
};
int main() {
A* p = new B();
p->show();
delete p;
}
- A.
A
- B.
AB
- C.
Compilation error
- D.
B
Sign up free to see the answer and a step-by-step explanation.