Question: Task: In C++ design a base class 'Shape' and an inheriting class 'Polygon' Specifications: - Base class 'Shape' should have a 'color' string and two

Task: In C++ design a base class 'Shape' and an inheriting class 'Polygon'

Specifications:

- Base class 'Shape' should have a 'color' string and two virtual functions 'calculateArea' and 'calculatePerimeter' which can be applied to the appropriate type of polygon inheriting the class.

- Inheriting class 'Polygon' should have a string 'type' to specify the polygon and an int for number of sides. The type of polygon will be determined by the number of sides [ex) 3 = 'triangle'] and the appropriate virtual member functions from 'Shape' will be applied to each polygon. The sides can never be less than 3 or negative.

** In the main function demonstrate the classes work without any user input only constructors

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!