zz c++操作符优先级表
from:http://www.cppreference.com/wiki//language/operator_precedence?redirect=1
C++ Operator Precedence
The operators at the top of this list are evaluated first. Operators within a group have the same precedence. All operators have left-to-right associativity unless otherwise noted.
Precedence | Operator | Description | Overloadable | Associativity |
---|---|---|---|---|
1 | :: |
scope resolution | no | left to right |
2 | () |
function call | yes | left to right |
[] |
array access | yes | ||
-> |
member access | yes | ||
. |
no | |||
++ -- |
postfix | yes | ||
dynamic_cast static_cast reinterpret_cast const_cast |
type conversion | no | ||
typeid |
Get type information | no | ||
3 | ! not |
logical negation | yes | right to left |
~ compl |
bitwise negation (complement) | yes | ||
++ -- |
prefix | yes | ||
+ - |
unary sign operations | yes | ||
* & |
indirection and reference | yes | ||
sizeof |
Size (of the type) of the operand in bytes | no | ||
new new[] delete delete[] |
dynamic memory management | yes | ||
(type) |
Cast to a given type | yes | ||
4 | ->* |
member pointer selector | yes | left to right |
.* |
member object selector | no | ||
5 | * / % |
arithmetic operations | yes | left to right |
6 | + - |
|||
7 | << >> |
shift operations | yes | left to right |
8 | < <= > >= |
relational operations | yes | left to right |
9 | == != not_eq |
|||
10 | & bitand |
bitwise AND | yes | left to right |
11 | ^ xor |
bitwise XOR | yes | left to right |
12 | | bitor |
bitwise OR | yes | left to right |
13 | && and |
logical AND | yes | left to right |
14 | || or |
logical OR | yes | left to right |
15 | ?: |
Ternary conditional (if-then-else) | no | right to left |
16 | = += -= *= /= %= &= ^= |= <<= >>= |
assignment | yes | right to left |
17 | , |
Sequential evaluation operator | yes | left to right |