previous | start | next

## Overloading Operators

- A commonly overloaded operator is the `==` operator, to compare two values.

  >     bool operator==(Time a, Time b)
  >     {
  >        return a.seconds_from(b) == 0;
  >     }

- For completeness, it is a good idea to also define a `!=` operator.

  >     bool operator!=(Time a, Time b)
  >     {
  >        return a.seconds_from(b) != 0;
  >     }

- You may also find it useful to define a `<` operator.

  >     bool operator<(Time a, Time b)
  >     {
  >        return a.seconds_from(b) < 0;
  >     }

previous | start | next