Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(C++) Write a class called Box that has three double fields called height, width and length. The class should have set methods for each field.

(C++) Write a class called Box that has three double fields called height, width and length. The class should have set methods for each field. It should have a three-parameter constructor that takes three doubles and passes them to the set methods to initialize the fields of the Box. It should have a default constructor that uses the set methods to initialize each field to 1. It should have a method that calculates and returns the volume of the Box and a method that calculates and returns the surface area of the Box.

The class declaration (interface) and the function definitions (implementation) must be in separate files - the interface or "header" file has a .hpp extension and the implementation has a .cpp extension. All data members should be private.

Your functions should have the following names:

setHeight

setWidth

setLength

getVolume

getSurfaceArea

The files must be named: Box.hpp and Box.cpp

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago