Create a class named GeometricShape containing Two data fields shapeType (a string) area (of type double)

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 5PE: Using classes, design an online address book to keep track of the names, addresses, phone numbers,...
icon
Related questions
Question

Create a class named GeometricShape containing  

Two data fields

 shapeType (a string)

area (of type double)

A no-argument constructor to initialize all data fields with default values “NoShape” and 0.0. A member function named show() to display the details associated with an instance of this class . Derive a class named Rectangle from class GeometricShape that includes Data members:

 Length(int)

 Width(int)

Respective mutater and accessor functions to set and get values of length and width, and function named computeArea() to compute the area of rectangle (length x width)  and function named show() to display the details associated with an instance of class Rectangle  and also its shape type attribute from parent class .From the Rectangle class, derive a class named Cuboid that contains  A data field named height in addition to length and width. A three arguments constructor to initialize the values (use super key word for length and width).Two functions named setHeight() and getHeight() to set and get value of height data field, and  function named computeArea() to calculate the area of a cuboid (length x width x height)  And function named show() to display the details associated with an instance of class Cuboid  and also shape type attribute from Shape class.

Implement these classes and in the main class with main method create instances of each class first set the values through setter function or constructors (take input from user).and then call the computeArea() and show()  methods of Rectangle and Cuboid class through there instances.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT