Question: Let explore the cube interface, implementation and client driver. Take note of some of the unexpected outcomes when changes are made to the existing code.

Let explore the cube interface, implementation and client driver. Take note of some of the unexpected outcomes when changes are made to the existing code.

Let's revise this class to implement each of these functions:

Constructor with parameters (increment numOfCubes)

Copy Constructor (increment numOfCubes)

Destructor to decrement numOfCubes

operator

operator!=()

Let's revise the main driver to:

declare a cube object, hisCube, that copies someCube's data values.

declare a cube object, herCube, that is initialized with 12, 5, 9

declare a cube pointer, ptrCube, that creates a dynamic cube with the values 10, 10, 10.

Display each cube variable using

Compare (!=) hisCube and someCube and display the result descriptively

expected output:

Let explore the cube interface, implementation and client driver. Take note of

my code so far:

#include #include #include #include #include using namespace std;

//////////////////////////// //Class Interface //////////////////////////// class cube{ friend ostream &operator

int cube::numOfCubes = 0;

int main(){ cube someCube, myCube, hisCube, herCube,PtrCube; someCube.set(2, 3, 4); myCube.set(10, 8, 2); herCube.set(12, 5, 9); hisCube = someCube; PtrCube.set(10, 10, 10); cout

cube::cube(){ length = 0; width = 0; height = 0; numOfCubes++; }

void cube::set(int l, int w, int h){ length = l; width = w; height = h; } int cube::volume()const{ return length*width*height; } void cube::print(){ cout

ostream &operator

cube::~cube(){ cout # of cubes created: 5 myCube...cube Information Length: 1e Width 8 Height: 2 volume(units 3) 16e Surface Area(units*2): 232 somecube...cube Information Length: 2 Width 3 Height: 4 Volume(units 3): 24 Surface Area(units 2): 52 hiscube...cube Information Length: 2 Width: 3 Height: 4 Volume(units 3): 24 Surface Area(units 2): 52 hercube...cube Information Length: 12 width 5 Height: 9 Volume (units 3): 54e Surface Area(units*2): 426 ptrcube...Cube Information Length: 1e Width: 1e Height: 1e volume (units^3): Surface Area(units*2): 6 1088 Comparing hiscube and somecube...Equal object is removed from memory object is removed from memory object is removed from memory object is removed from memory object is removed from memory

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!