Question
For each of the following classes -create default constructor and parameterized constructors(calling parent(s) parameterized constructors where it applies -Add accessor and mutator function for the
For each of the following classes
-create default constructor and parameterized constructors(calling parent(s) parameterized constructors where it applies
-Add accessor and mutator function for the attribute inherit to the class
Create a Base class called Shape2d
-with the protected floating point attribute area
-operator overload the + & - and operations to return the float respective to the area
Derive from the a Base class from called Shape2d called Rectangle
-with the additional floating point attributes length & width
Derive from the a Base class from called Shape2d called Circle
-with the additional floating point attributes radius
Create the Base class called Shape3d
-with the protected floating point attribute volume
-operator overload the *(have it add) & /(have it subtract) and operations to return the float respective to the volume
Derive from both Rectangle and Shape3d a class called Box
-with the additional floating point attributes height
Derive from both Circle and Shape3d a class called Cylinder
-with the additional floating point attributes height
For each of following classes [Circle, Rectangle, Box & Cylinder] create 3 instances each (using the parameterized constructor {no interactive input required}
Demonstrate the + & - operation overloading using the following combinations
Circle + Circle Rectangle + Rectangle Rectangle + Circle Circle - Circle Rectangle - Rectangle Rectangle - Circle | Box + Box Rectangle + Box Box + Circle Box - Circle Rectangle - Box Box - Circle | Cylinder + Cylinder Rectangle + Cylinder Cylinder + Circle Cylinder - Circle Rectangle - Cylinder Rectangle - Cylinder |
Demonstrate the * & / operation overloading using the following combinations
Box * Box Cylinder * Cylinder Box * Cylinder | Box / Box Cylinder / Cylinder Box / Cylinder |
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