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
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