Question
This is for C++ Problem Implement a hierarchy of Shape s to demonstrate the OOP concepts of inheritance and polymorphism. Specification 1. Create class Shape
This is for C++
Problem
Implement a hierarchy of Shapes to demonstrate the OOP concepts of inheritance and polymorphism.
Specification
1. Create class Shape that will serve as the base class for several types of Shapes. Declare data members in the Shape class for a description ("circle", "triangle", etc.) and an area, and include appropriate accessor (get) and mutator (set) functions. Also declare a virtual calcArea()function.
2. Derive classes Rectangle, Circle, and Triangle from class Shape. For each of these classes, include appropriate data members and implement the calcArea() function.
3. Create an array of at least 5 Shape pointers and fill the array with the addresses of several different kinds of shapes.
4. Use a for loop to calculate and print the description and area of each Shape in the array.
5. Include a multi-line comment in your program that describes the difference between static (early) binding and dynamic (late) binding and how dynamic binding facilitates polymorphic precessing.
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