Defining Multiple Operators

Let’s discuss how to overload multiple operators simultaneously.

Use of multiple operators

To keep the code samples short, we have used only the ++, +, and += operators. It is conceivable that when one operator is overloaded for a type, many others would also need to be overloaded. For example, the -- and -= operators are also defined for the following Duration:

Get hands-on with 1000+ tech skills courses.