Create a base class called shape, this class to store two double type values (value1, value2) that could be used to compute the area of figures. Derive two specific classes called triangle and rectangle from the base shape. Add accessor and mutator function to the base class, to initialize and retrieve base class data members and another member function display_area() to compute and display area of figures.. Make display_area as pure virtual function and provide its definition in the derived class to suit their requirements. Using these three classes, design a program that will accept dimensions of a triangle or a rectangle interactively and display area. Run the above program with following requirements. Provide appropriate constructor in each class. Use constructor function to initialize the data members of base class.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 1PE: In Chapter 10, the class clockType was designed to implement the time of day in a program. Certain...
icon
Related questions
Question

Create a base class called shape, this class to store two double type values (value1, value2) that could be used to compute the area of figures. Derive two specific classes called triangle and rectangle from the base shape. Add accessor and mutator function to the base class, to initialize and retrieve base class data members and another member function display_area() to compute and display area of figures.. Make display_area as pure virtual function and provide its definition in the derived class to suit their requirements.

Using these three classes, design a program that will accept dimensions of a triangle or a rectangle interactively and display area.

Run the above program with following requirements.

  1. Provide appropriate constructor in each class.
  2. Use constructor function to initialize the data members of base class.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning