Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A short class named Polygon is provided. Your job is to finish its implementation, and then finish extending the inheritance tree with Rectangle and Triangle
A short class named Polygon is provided. Your job is to finish its implementation, and then finish extending the inheritance tree with Rectangle and Triangle Then add to the hierarchy by adding a Shape class to the root (meaning that the existing hierarchy should extend Shape). Shape should have a position, [x,y) in a coordinate plane. Then derive a Circle class from Shape, and an Ellipse class. Suppose you wanted to add a perimeter function. Where in the hierarchy should this be added? Add this function. Create your own hierarchy of objects with the third dimension. cube, pyramid, sphere) Area no longer makes sense, but what else does? Here is the code to start: #include using namespace sto; class Polygon ( protected double width, height; public: void set_w_h (double a, double b) // Private members are hidden from children {width-a; height-b;) virtual double get area0) 0; // This is a pure virtual function class Rectangle: public Polygon{ // default is private public: double get_area O ( return 0; )
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started