Skip to content

Latest commit

 

History

History
71 lines (46 loc) · 3.1 KB

expressions-with-unary-operators.md

File metadata and controls

71 lines (46 loc) · 3.1 KB
description Learn more about: Expressions with Unary Operators
title Expressions with Unary Operators
ms.date 11/04/2016
helpviewer_keywords
expressions [C++], unary operators
unary operators [C++], expressions with
expressions [C++], operators
ms.assetid 1217685b-b85d-4b48-9ff4-d90f56a26c1b

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.

Syntax

unary-expression:
  postfix-expression
  ++ cast-expression
  -- cast-expression
  unary-operator cast-expression
  sizeof unary-expression
  sizeof ( type-id )
  sizeof ... ( identifier )
  alignof ( type-id )
  noexcept-expression
  new-expression
  delete-expression
unary-operator: one of
  * & + - ! ~

Remarks

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

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

The noexcept-expression is a noexcept-specifier with a constant-expression argument. For more information, see noexcept.

The new-expression refers to the new operator. The delete-expression refers to the delete operator. For more information, see new operator and delete operator.

See also

Types of expressions