Question OOP-ABS-0061
HardWhat is the output of this code?
#include <iostream>
using namespace std;
class Shape {
public:
virtual double area() const = 0;
virtual ~Shape() = default;
double twice() const { return 2 * area(); }
};
class Sq : public Shape {
double s;
public:
Sq(double x) : s(x) {}
double area() const override { return s * s; }
};
{
Shape &s = ();
cout << s.();
}
- A.
9
- B.
Compilation error
- C.
Sign up free to see the answer and a step-by-step explanation.