C++ Assignment (DO NOT COPY AND PASTE FROM CHEGG) Overload the = operator for your Rectangle class, it should return a Rectangle in order to support multiple assignments in one line, e.g. a = b = c;, and add the rest of"Rectangel.h". Overload the < and > operators in Rectangle to determine if one rectangle is bigger than the other, based on area. Demonstrate that your new operators work by writing a simple main() function to show they work. Rectangle.h class Rectangle { private: double width; double length; char *name; void initName(char* n); public: Rectangle(); Rectangle(double, double, char*); Rectangle(Rectangle &); ~Rectangle(); Rectangle& operator=(const Rectangle &); Rectangle operator+(const Rectangle &r) { Rectangle newRect; newRect.width = width+r.width; newRect.length = length+r.length; newRect.setName(name); return newRect; } void setName(char *); ... };
C++ Assignment (DO NOT COPY AND PASTE FROM CHEGG)
Overload the = operator for your Rectangle class, it should return a Rectangle in order to support multiple assignments in one line, e.g. a = b = c;, and add the rest of"Rectangel.h".
Overload the < and > operators in Rectangle to determine if one rectangle is bigger than the other, based on area.
Demonstrate that your new operators work by writing a simple main() function to show they work.
Rectangle.h
class Rectangle
{
private:
double width;
double length;
char *name;
void initName(char* n);
public:
Rectangle();
Rectangle(double, double,
char*);
Rectangle(Rectangle &);
~Rectangle();
Rectangle& operator=(const Rectangle &);
Rectangle operator+(const Rectangle &r)
{
Rectangle newRect;
newRect.width = width+r.width;
newRect.length = length+r.length;
newRect.setName(name);
return newRect;
}
void setName(char *);
...
};
Trending now
This is a popular solution!
Step by step
Solved in 3 steps