12. The box class provides measurem ent of a box that is defined by its length,
ID: 3888733 • Letter: 1
Question
12. The box class provides measurem ent of a box that is defined by its length, width, and height. Store the base of the box as a rectangle object using object composition. height width length class box public: box (double 1, double w, double h): height (h) -, double volume () // length* width + height double getLength) return private: rectangle base; double height (a) Complete the initialization list for the constructor so that the rectangle object base gets initialized. (b) Give the return value for getLength). (c) Implement the member function volume).Explanation / Answer
Dear Student,
below i have completed the class as per the requirement...
-----------------------------------------------------------------------------------------------------------------------------------------
class box
{
public:
box(double l, double w, double h):length(l), width(w),height(h){}
double volume()
{
double V = height * width *length;
return V;
}
double getLength()
{
return length;
}
private:
rectangle base;
double height;
};
-----------------------------------------------------------------------------------------------------------------------------------------
Kindly Check and Verify Thanks...!!!
------------------------------------------------------------------------------------------------------------------------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.