You are here

Unary Positive -Worthless

5 February, 2015 - 11:20

Simply to satisfy symmetry, the unary positive was added to the C++ programming language as on operator. However, it is a totally worthless or useless operator and is rarely used. However don't be confused the following expression is completely valid:

6 + +5 

The second + sign is interpreted as unary positive. The first + sign is interpreted as addition.

money +money money * +l 

For all three lines, if the value stored in money is 6 the value of the expression is 6. Even if the value in money was negative 77 the value of the expression would be negative 77. The operator does nothing, because multiplying anything by 1 does not change its value.