Unary Operators
Unary operators have only one operand. They include increment and decrement operators, negation operators, logical and bitwise negation, positive and negative sign operators, cast, address, and dereference operators, and operators new, delete, and sizeof. All these operators (with the exception of sizeof) can be overloaded.
Of course, not every operator can have its own special meaning for every class. In Chapter 10, I overloaded the positive sign operator for class Complex as an output operator, and this design is confusing. This is why overloading of unary operators is not very popular. However, there are some situations where these operators can contribute to intuitive understanding of the client code. In this section, I will ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access