Question OOP-ABS-0042
MediumWhat is the output of this code?
#include <iostream>
using namespace std;
class Shape {
public:
virtual double area() = 0;
void info() { cout << "Area=" << area(); }
};
class Rect : public Shape {
public:
double area() override { return 4 * 5; }
};
int main() {
Rect r;
r.info();
}
- A.
Area=20
- B.
Compilation error
- C.
Area=45
- D.
Area=0
Sign up free to see the answer and a step-by-step explanation.