Purchase Solution

C++ Square and Cube classes

Not what you're looking for?

Ask Custom Question

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.)

Purchase this Solution

Solution Summary

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.

Solution Preview

Attached solution 569148.cpp creates a base class Square, and derives class Cube from it as per the given specifications. It also ...

Purchase this Solution


Free BrainMass Quizzes
Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Javscript Basics

Quiz on basics of javascript programming language.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.