Note:
- Operator Precedence not affect the operator overloading .
- For study C ++ operator precedence, reference may cppreference
, which provides detailed annotations.
Post author Author: Gray
Copyright Notice Copyright: the Except the WHERE otherwise Noted, All Content of the this Blog IS A Licensed an under CC BY-the NC-SA 4.0 International's License . Unless otherwise stated, all articles on this blog are subject to Creative Commons Attribution - nonCommercial - ShareAlike 4.0 international license agreement for protection.
priority | Operators | Associativity | Mnemonic |
---|---|---|---|
1 | :: |
from left to right | Scope |
2 | a++ 、a-- 、type() 、type{} 、a() 、a[] 、. 、-> |
from left to right | Postfix increase or decrease the function transformation of style, function calls, subscript, member access |
3 | ! 、~ 、++a 、--a 、+a 、-a 、(type) 、sizeof 、&a 、*a 、new 、 new[] 、delete 、 delete[] |
from right to left | Logical NOT, bitwise, Prefix decrease, positive and negative, C transition style, size fetch, fetch address, pointer accesses, dynamic memory allocation |
4 | .* 、->* |
from left to right | Pointing member pointer |
5 | a*b 、a/b 、a%b |
from left to right | Multiplication and division, modulo |
6 | a+b 、a-b |
from left to right | Addition and subtraction |
7 | << 、>> |
from left to right | Bitwise shift left and right |
8 | < 、<= 、> 、>= |
from left to right | Size comparison |
9 | == 、!= |
from left to right | Compare equivalence |
10 | a&b |
from left to right | Bitwise AND |
11 | ^ |
from left to right | Bitwise XOR |
12 | | |
from left to right | Bitwise or |
13 | && |
from left to right | Logic and |
14 | || |
from left to right | Logical or |
15 | a?b:c 、= 、+= 、-= 、*= 、/= 、%= 、&= 、^= 、|= 、<<= 、>>= |
from right to left | Ternary conditional, assignment |
16 | , |
from left to right | comma |