Via operator overloading we can use operators among class instances.
The key for operator predefining is to create function named
specifically via the keyword operator.
For example a + operator can be predefined via a function named
operator+
> operator can be predefined via a function named
operator> and so on.
Output:
Line 32 sums two class objects.
This executes the code of the predefining operator function
(lines 18 - 23).
Output:
Lines 33, 38 and 43 compare objects via the operator ==.
To compare them the code from the operator predefined function
is used (lines 19 - 24).
Output: