Consider the class Rectangle class Rectangle f public Rectangle double 1 double w double

Consider the class Rectangle: class Rectangle { public: Rectangle(double 1, double w); double area() const; double getLength() const; double getWidth() const; private: double length; double width; }; (a) Derive a class Box from the class Rectangle. Provide only the interface for the class Box. The class Box has an additional private member variable height, and an additional public member function volume(). Include an accessor for the member variable height. Redefine the area() member function for the class Box. (6) (b) Implement the member function area() for the class Box. The outside surface area of a box is 2(hW) + 2(hL) + 2(WL), where h represents the height of the box, and W and L the width and length of the box respectively. (3)

Consider the class Rectangle:

class Rectangle {
public:
Rectangle(double 1, double w);
double area() const;
double getLength() const;
double getWidth() const;
private:
double length;
double width;
};

(a) Derive a class Box from the class Rectangle. Provide only the interface for the class Box. The class Box has an additional private member variable height, and an additional public member function volume(). Include an accessor for the member variable height. Redefine the area() member function for the class Box. (6)

(b) Implement the member function area() for the class Box. The outside surface area of a box is 2(hW) + 2(hL) + 2(WL), where h represents the height of the box, and W and L the width and length of the box respectively. (3)


 
Solved By Verified
Study Co-Pilot All Study Co-Pilots are evaluated by Gotit Pro as an expert in their subject area.

 
Instant
Download

Student review: (2 ratings) 2 out of 2 people found this solution helpful.