Question
Must be completed in C++ Complete the following tasks: a. Create a base class named Rectangle that includes data members for the length and width
Must be completed in C++
Complete the following tasks: a. Create a base class named Rectangle that includes data members for the length and width of a Rectangle, as well as functions to assign and display those values. Derive a class named Block that contains an additional data member to store height, and contains functions to assign and display the height. Write a main() function that demonstrates the classes by instantiating and displaying the values for both a Rectangle and a Block. Save the file as RectangleAndBlock.cpp.
b. Add a member function to the Rectangle class that computes the area of a Rectangle (length multiplied by width). Add a member function to Block that has the same name, but overrides the computation with a volume calculation (length by width by height). Write a main() function that demonstrates the classes. Save the file as RectangleAndBlock2.cpp
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