Question: Consider the following simple class: class Rectangle { private: double length, width; public: Rectangle ( double l, double w ){ length = l; width =
Consider the following simple class:
class Rectangle
{
private:
double length, width;
public:
Rectangle ( double l, double w ){ length = l; width = w; }
double area() { return length * width; }
double perimeter(){ return 2* ( length + width ); }
};
Consider the following class that uses the Rectangle class defined above:
class artItem
{
private:
Rectangle canvas;
String title;
};
a) Write a constructor which initializes the canvas, and the title. The constructor
receives a string parameter to initialize the title and the length and width to pass to the
Rectangle copy constructor when creating the canvas object.
b) Write a print method that prints the title and prints the perimeter and the area of canvas
call the methods area and perimeter to get both values.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
