previous | start | next

## Operator Overloading

- Does it make sense to add two times?

  >     some_return_type operator+(Time a, Time b);

- A `Time` objects represent a point in time, not a duration: what does 3 P.M. + 3 P.M. mean?
- It does make sense to add a number of seconds to a `Time` object, resulting in a new `Time` object.

  >     Time operator+(Time a, int sec)
  >     {
  >        Time r = a;
  >        r.add_seconds(sec);
  >        return r;
  >     }

previous | start | next