Well I assume he/she means to derive a new object from a Rectangle. In that case you might do something like:
Code:
class Rectangle3D : public Rectangle {
double depth;
public:
Rectangle3D(double l, double w, double d)
: Rectangle(l, w), depth(d)
{}
void setSides( double l, double w, double h)
{
Rectangle::setSides(l, w);
depth = d;
}
};
For the area function, just keep in mind that there are really only 3 sides to consider, since each is mirrored by an identical rectangle.
Here's an example of using the existing class:
Code:
double Rectangle3D::area()
{
Rectangle s2(width, depth),
s1(height, depth);
return (s1.area()*2) + (s2.area()*2) + (this->Rectangle::area()*2);
}