Operators decrease in priority from top to bottom, and operators in the same row have the same precedence. The second line is all unary operators.
| Operator |
Explain |
How to combine |
| () []- >. |
|
left-to-right |
| ! ~ + +--+- * & ( ) sizeof |
negation, bitwise negation, Increment, decrement, sign, Indirect, take address, type convert, size |
from right to left /span> |
| * / % |
Multiply, divide, take the mold |
From left to right |
| + - |
Add, Subtract |
From left to right |
| << >> |
Move left, move right |
From left to right |
| < <= >= > |
Less than, equal to, greater than or equal to, greater than |
From left to right |
| == != |
Equal to, not equal to |
From left to right |
| & |
Bitwise-AND |
From left to right |
| ^ |
Bitwise XOR OR |
From left to right |
| | |
Bitwise OR |
From left to right |
| && |
Logic and |
From left to right |
| || |
Logical OR |
From left to right |
| ? : |
Conditions |
From right to left |
| = += -= *= /= &= ^= |= <<= >>= |
Various assignment values |
From right to left |
| , |
Comma (order) |
From left to right |
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
C++/C operator Table