Consider the following code segment(something that won't affect the worldview and comprehension can be already omitted.)
class Rectangle
{
private:
double left,top;
double right,bottom;
public:
double length() { return fabs(right-left); }
double heigh(){ return fabs(bottom-top);}
Rectangle operator+(const Rectangle& rival) const;
//.....and so on
}
Now let's look at the definitionof the overloading function of operator +
Rectangle Rectangle::operator+(const Rectangle& rival)const
{
Rectangle temp=*this;
temp.right=this->right+fabs(rival.length());
temp.bottom=this->bottom+fabs(rival.heigh());
return temp;
}
Notice that the argument passed to the function is a const reference to a class Rectangle (const Rectangle& rival). This function will create