A unary expression contains one operand and a unary operator. All unary operators have the same precedence and have right-to-left associativity. A unary expression is therefore a postfix expression.
As indicated in the following descriptions, the usual arithmetic conversions are performed on the operands of most unary expressions.
The following table summarizes the operators for unary expressions:
Precedence and associativity of unary operators | |||
Rank | Right Associative? | Operator Function | Usage |
---|---|---|---|
3 | yes | size of object in bytes | sizeof ( expr ) |
3 | yes | size of type in bytes | sizeof type |
3 | yes | prefix increment | ++ lvalue |
3 | yes | prefix decrement | -- lvalue |
3 | yes | complement | ~ expr |
3 | yes | not | ! expr |
3 | yes | unary minus | - expr |
3 | yes | unary plus | + expr |
3 | yes | address of | & lvalue |
3 | yes | indirection or dereference | * expr |
3 | yes |
![]() | new type |
3 | yes |
![]() | new type ( expr_list ) type |
3 | yes |
![]() | new type ( expr_list ) type ( expr_list ) |
3 | yes |
![]() | delete pointer |
3 | yes |
![]() | delete [ ] pointer |
3 | yes | type conversion (cast) | ( type ) expr |
Related References
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.