Question: C++ Inheritance and Polymorphism Could someone please help me with this question in C++. Helpwould be much appreciated. Thanks! Starter code for the second question:___#include
C++ Inheritance and Polymorphism
Could someone please help me with this question in C++. Helpwould be much appreciated. Thanks! 
Starter code for the second question:___#include#include // Add your code herevoid report(const Shape *s){ std::cout sides() perimeter()
Inheritance and Polymorphism 1. Create an inheritance hierarchy that shows the relationships between the following classes. You do not need to implement the classes. Watercraft, Airplane, Car, HotAirBalloon, Canoe, Vehicle, Boat, Aircraft, Sailboat, Helicopter, MotorVehicle, Motorbike void report (const Shape *s) { std::cout < < "sides: " < < s->sides() < < ", "; std::cout < < "perimeter: " < < < s->perimeter() < < ''; } 2. Devise and implement a class hierarchy that would cause this code to produce the outputs indicated. You will need to decide what classes are needed, what methods and attributes they have, and which class inherits from which. int main() { } Rectangle r(5.3, 8.4); Circle c(1.75); report(&r); report (&c); // sides: 4, perimeter: 27.4 // sides: 0, perimeter: 10.9956 Example hierarchy format: Class A Class B The formula to calculate the perimeter of a rectangle is: 2(w + h) The formula to calculate the perimeter (circumference) of a circle is: 2 R Class C Class D Include the cmath header to use M_PI
Step by Step Solution
3.48 Rating (158 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
