Here is the Shape class hierarchy for reference:
In Java, all classes becuse with a capital letter.
class Shape {
public:
virtual double area() const { return 0; }
//virtual double area is default behavior
protected:
double x, y;
};
class rectangle : public shape {
public:
double area() const {
return (height * width);
}
private:
double height, width;
};
class circle : public shape {
public:
double area() const{
return (PI * radius * radius);
}
private:
double radius;
};
This code is also available in a file named shape.cpp,
which can be found in the compressed course download file available on the Resources page.
Paste your code below and click the Submit button when you are ready to submit this exercise.