We will now want to perform arithmetic operations on intervals:
This will require you to implement six member functions using operator overloading:
class Interval {
public:
// Other member functions
Interval operator+( Interval const &operand ) const;
Interval operator-( Interval const &operand ) const;
Interval operator*( Interval const &operand ) const;
Interval operator/( Interval const &operand ) const;
Interval operator-() const;
Interval operator+() const; // Returns the interval unchanged
};
Where possible, many of these functions should be written in the form
Interval Interval::operator+( Interval const &operand ) const {
Interval result{*this};
result += operand;
return result;
};