
Operator Overloading 169
For example, the equality operator (==) requires two operands. It is not possible to
implement the
operator function for == by using less than or more than two operands.
(ii) There are some operators that are unary as well as binary. For example,
⫹, ⫺ and *
are unary as well as binary operators.
a=⫹5; // ⫹ as unary operator
a=4⫹9; // ⫹ as binary operator
a=⫺5; // ⫺ as unary operator
a=4⫺9; // ⫺ as binary operator
c=*p; // * as unary operator (dereferencing operator)
c=5*8; // * as binary operator
(iii) It is not possible to create new operators. Only existing operators can be overloaded.
For example, one cannot create a ...