Compartir a través de


Expressions with Unary Operators

 

The latest version of this topic can be found at Expressions with Unary Operators.

Unary operators act on only one operand in an expression. The unary operators are as follows:

These operators have right-to-left associativity. Unary expressions generally involve syntax that precedes a postfix or primary expression.

The following are the possible forms of unary expressions.

  • postfix-expression

  • ++ unary-expression

  • –– unary-expression

  • unary-operator cast-expression

  • sizeof unary-expression

  • sizeof( type-name )

  • decltype( expression )

  • allocation-expression

  • deallocation-expression

Any postfix-expression is considered a unary-expression, and because any primary expression is considered a postfix-expression, any primary expressions is considered a unary-expression also. For more information, see Postfix Expressions and Primary Expressions.

A unary-operator consists of one or more of the following symbols: * &``+``–``!``~

The cast-expression is a unary expression with an optional cast to change the type. For more information see Cast Operator: ().

An expression can be any expression. For more information, see Expressions.

The allocation-expression refers to the new operator. The deallocation-expression refers to the delete operator. For more information, see the links earlier in this topic.

See Also

Types of Expressions