Unary Operators in C++

C++ includes a class of operators that act upon a single operand to produce a new value. Such operators are known as unary operators. Unary operators usually precede their single operands, through some unary operators are written after their operands.

Perhaps the most common unary operation is unary minus, where a numerical constant, variable or expression is preceded by a minus sign.

Note that the unary operation is distinctly different from the arithmetic operator which denotes subtraction (-) as the subtraction operator requires two operands.


-743 -0x7fff -0.2 -5E-8
-root1 -(x + y) -3 * (x + y)

You may also like...

2 Responses

  1. Leandro says:

    Hello There. I found your blog the use of msn. This is a
    really neatly written article. I’ll be sure to bookmark it and return to learn extra of your useful
    info. Thanks for the post. I will certainly return.

  1. August 11, 2013

    […] Unary operators […]

Leave a Reply

Your email address will not be published. Required fields are marked *