Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Oracle Solaris 11 System Administration

Authors: Bill Calkins

1st Edition

0133007170, 9780133007176

More Books

Students also viewed these Databases questions