Precedence | Operator | Description | Example | Associativity |
---|---|---|---|---|
1 | () [] -> . :: ++ -- |
Grouping operator Array access Member access from a pointer Member access from an object Scoping operator Post-increment Post-decrement |
(a + b) / 4; array[4] = 2; ptr->age = 34; obj.age = 34; Class::age = 2; for( i = 0; i < 10; i++ ) ... for( i = 10; i > 0; i-- ) ... |
left to right |
2 | ! ~ ++ -- - + * & (type) sizeof |
Logical negation Bitwise complement Pre-increment Pre-decrement Unary minus Unary plus Dereference Address of Cast to a given type Return size in bytes |
if( !done ) ... flags = ~flags; for( i = 0; i < 10; ++i ) ... for( i = 10; i > 0; --i ) ... int i = -1; int i = +1; data = *ptr; address = &obj; int i = (int) floatNum; int size = sizeof(floatNum); |
right to left |
3 | ->* .* |
Member pointer selector Member pointer selector |
ptr->*var = 24; obj.*var = 24; |
left to right |
4 | * / % |
Multiplication Division Modulus |
int i = 2 * 4; float f = 10 / 3; int rem = 4 % 3; |
left to right |
5 | + - |
Addition Subtraction |
int i = 2 + 3; int i = 5 - 1; |
left to right |
6 | << >> |
Bitwise shift left Bitwise shift right |
int flags = 33 << 1; int flags = 33 >> 1; |
left to right |
7 | < <= > >= |
Comparison less-than Comparison less-than-or-equal-to Comparison greater-than Comparison geater-than-or-equal-to |
if( i < 42 ) ... if( i <= 42 ) ... if( i > 42 ) ... if( i >= 42 ) ... |
left to right |
8 | == != |
Comparison equal-to Comparison not-equal-to |
if( i == 42 ) ... if( i != 42 ) ... |
left to right |
9 | & | Bitwise AND | flags = flags & 42; | left to right |
10 | ^ | Bitwise exclusive OR | flags = flags ^ 42; | left to right |
11 | | | Bitwise inclusive (normal) OR | flags = flags | 42; | left to right |
12 | && | Logical AND | if( conditionA && conditionB ) ... | left to right |
13 | || | Logical OR | if( conditionA || conditionB ) ... | left to right |
14 | ? : | Ternary conditional (if-then-else) | int i = (a > b) ? a : b; | right to left |
15 | = += -= *= /= %= &= ^= |= <<= >>= |
Assignment operator Increment and assign Decrement and assign Multiply and assign Divide and assign Modulo and assign Bitwise AND and assign Bitwise exclusive OR and assign Bitwise inclusive (normal) OR and assign Bitwise shift left and assign Bitwise shift right and assign |
int a = b; a += 3; b -= 4; a *= 5; a /= 2; a %= 3; flags &= new_flags; flags ^= new_flags; flags |= new_flags; flags <<= 2; flags >>= 2; |
right to left |
16 | , | Sequential evaluation operator | for( i = 0, j = 0; i < 10; i++, j++ ) ... | left to right |
C++ 運算子優先順序列表
相關文章
- C++運算子優先順序C++
- C++運算子優先順序特例C++
- C++ 運算子優先順序表C++
- java運算子優先順序Java
- php運算子優先順序PHP
- Python 運算子優先順序 運算子Python
- python運算子及優先順序順序Python
- C 語言運算子優先順序
- C語言運算子優先順序C語言
- JS與&& 或||運算子 優先順序JS
- 介紹python中運算子優先順序Python
- java字串連線和運算子優先順序Java字串
- JavaScript陰溝裡翻船之運算子優先順序JavaScript
- Like Sunday, Like Rain - JavaScript運算子優先順序AIJavaScript
- 各類運算子和計算方法,優先順序
- ORACLE中sql語句----運算子的優先順序OracleSQL
- oracle plsql儲存過程_運算子優先順序OracleSQL儲存過程
- VBA運算子的型別及優先順序(轉)型別
- C語言運算子優先順序列表(超詳細)C語言
- C語言常被搞錯的運算子優先順序C語言
- Java常見知識點彙總(⑤)——運算子優先順序Java
- lodash原始碼分析之baseFindIndex中的運算子優先順序原始碼Index
- [java基礎] 之 表示式和運算子的優先順序Java
- 程式設計答疑:記不住運算子優先順序怎麼辦?程式設計
- 面試題:物件的儲存形式 和 . 運算子的優先順序面試題物件
- Solidity語言學習筆記————8、運算子優先順序Solid筆記
- javascript基礎(賦值運算子,關係運算子,相等運算子,三元運算子,運算子的優先順序,程式碼塊)(十)JavaScript賦值
- 運算子的關係,什麼叫一元運算子,二元運算子,三元運算子,運算子優先順序,以及運算子的
- C語言運算子優先順序列表(超詳細) 轉自 @RoninwzC語言
- 如果你不懂js運算子優先順序,那絕對不是js高手。JS
- C++操作符的優先順序C++
- CSS優先順序CSS
- js運算子優先順序及賦值運算var a = {n:1};var b = a;a.x = a = {n:2};JS賦值
- 中斷優先順序
- [JAVA] 不僅有Java運算子,更有優先順序講解,可以說很詳細了Java
- Android程式優先順序Android
- SQL 優先順序join>whereSQL
- nginx快取優先順序Nginx快取