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

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!