USING C++ Overload the = operator for your Rectangle class, Rectangle class is below , it should return a Rectangle in order to support multiple assignments in one line, e.g. a = b = c;. Copying from...


USING C++



  • Overload the = operator for your Rectangle class,Rectangle class is below, it should return a Rectangle in order to support multiple assignments in one line, e.g. a = b = c;. Copying from the pdfs is acceptable, but make sure you understand how it works.

  • 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 Class ***


Rectangle.h
class Rectangle
{
private:
double width;
double length;
char* name;
void initName(char* n);
public:
Rectangle();
Rectangle(double, double,
char*);
//Copy Constructor
Rectangle(Rectangle&);
~Rectangle();
Rectangle& operator=(const Rectangle&);
...
};


****End of Rectangle Class****


****Overloaded = operator, returns a rectangle by reference****


Rectangle.cpp


Rectangle& Rectangle::operator=(const Rectangle& r)
{
length = r.length;
width = r.width;
strcpy(name, r.name);
return *this;
}


*** End of overloaded operators***



Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here