Derive the cube class from the base square class. Assume the square class has a protected member variable representing the side called side and declared as a double with a default value of 1.0. It also has a public function called calcVal that evaluates the area of a square as side * side.
In your derived class have the default values for side be 1. For the cube class include a public function calcVal that evaluates the volume of the cube. (Hint: The volume of the cube is side * square :: calcVal.)© BrainMass Inc. brainmass.com October 10, 2019, 7:08 am ad1c9bdddf
Attached solution 569148.cpp creates a base class Square, and derives class Cube from it as per the given specifications. It also ...
Solution creates a base class 'Square' with protected member 'side'. It then derives class 'Cube' from it that makes use of 'side' from parent class, and also overrides 'calcVal' method of the parent class.