Question OOP-POLY-0063
HardWhat is the output of this code?
#include <iostream>
using namespace std;
class A {
public:
virtual void show() { cout << "A"; }
};
class B : public A {
public:
void show() override { cout << "B"; }
};
int main() {
B b;
A a = b;
A &r = b;
A *p = &b;
a.show(); r.show(); p->show();
}
- A.
BBB
- B.
BAB
- C.
Sign up free to see the answer and a step-by-step explanation.