Question: C++ Help. PLEASE FOLLOW ALL DIRECTIONS. PLEASE INCLUDE COMMENTS. PLEASE INCLUDE SCREENSHOTS OF HOW TO SET UP IN DEVELOPMENT ENVIRONMENT. Thank you! Define a class
C++ Help. PLEASE FOLLOW ALL DIRECTIONS. PLEASE INCLUDE COMMENTS. PLEASE INCLUDE SCREENSHOTS OF HOW TO SET UP IN DEVELOPMENT ENVIRONMENT. Thank you!
Define a class Box which implements the overloaded operators described in the driver given below.
The default Box is a box where the length, width and depth are equal to 1. (10%)
The overloaded arithmetic operators perform the operations on the sides of the Box (i.e. operator+() will add the length, width and depth of the two boxes). (40%)
When comparing boxes, you should compare the volume of the boxes. (10%)
The unary ++ operator should increment all sides by one. (10%)
When displaying a box, you should display the dimension, volume and area of the box. (10%)
NOTE: If the operation results in a side length <=0 then change the Box side length to 1 by default.
include
#include "box.h"
using namespace std;
int main()
{
Box box1(10, 5, 3);
Box box2(8, 7, 5);
Box box3;
Box box4;
Box box5;
cout << "box1: " << box1 << endl;
cout << "box2: " << box2 << endl;
box3 = box1 + box2;
cout << "box1 + box2 = " << "box3: " << box3 << endl;
box4 = box1 - box2;
cout << "box1 - box2 = " << "box4: " << box4 << endl;
box5 = box1 * box2;
cout << "box1 * box2 = " << "box5: " << box5 << endl;
if (box1 > box2)
cout << "Volume of box1 is greater than the volume "
<< "of box2 ." << endl;
else
cout << "Volume of box1 is less than or equal to the volume "
<< "of box2 ." << endl;
box1++;
cout << "After increment the length, width, and height of "
<< "box1 by one unit, box1: "
<< box1 << endl;
box4 = ++box3;
box4 = box3++;
cout << "New dimension of box3: " << box3 << endl;
cout << "New dimension of box4: " << box4 << endl;
cout <<"Box4 is "<< (box4 != box3 ? "Not Equal to Box3 " : "Equal to Box3") << endl;
cout << "Box4 is " << (box4 >= box3 ? "Greater or Equal to Box3 " : "Not Greater or Equal to Box3 ") << endl;
cout << "Box4 is " << (box4 == box3 ? "Equal to Box3 " : "Not Equal to Box3") << endl;
cout << "Box4 is " << (box4 < box3 ? "Less Than Box3 " : "Not Less Than to Box3") << endl;
cout << "Box4 is " << (box4 <= box3 ? "Less Than or Equal to Box3 " : "Not Less Than or Equal to Box3") << endl;
system(pause);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
