Write accessor funtions for height width and depthalso what


Given below is a c++ class called Sbox used in shipping.

We can declare an object of type Sbox to hold the dimensions of a shipping box, a height, width and depth. We define a height (h), width (w) and depth (d) for the three sides of a box. For shipping, it is required the height to be no greater than 45 inches. The width cannot be anymore than 75% of the box's height. The depth must be less than the height.

Class Sbox
{
Private:
Int h, w, d; // height width depth

1. Write a constructor function that
A) defines an object with default value of 0s
{
public:
Sbox ()
.............
};

Sbox::Sbox()
{ h=0; w=0; d=0;}

b) define an object with the initial values for h, w, and d. check for the constraints listed earlier
Sbox::Sbox (int h, int w, int d)
{
if (h<45 && (w{
this->h=h;
this->w=w;
this->d=d;
}
else {
this->h=0;
this->w=0;
this->d=0;
}

}

2. Write accessor funtions for height, width, and depth.
Also, what exactly is an accessor function?

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Write accessor funtions for height width and depthalso what
Reference No:- TGS01245903

Now Priced at $20 (50% Discount)

Recommended (91%)

Rated (4.3/5)