| Start |
|---|
| Logical && and || operators: short-circuit && has precedence over ||, this means that parentheses are placed to evaluate what would be evaluated together. c++ uses short-circuit evaluation in && and || to not do unnecessary executions. |
| Arithmetic operators Arithmetic operators in C++ have the same precedence as they do in mathematics: Multiplication and division have left associativity(meaning that they will be evaluated from left to right) and they have higher precedence than addition and subtraction, which also have left associativity. We can also force the precedence of expression using parentheses |
| Logical AND and OR operators These operators have the usual precedence in C++: AND before OR. This code is equivalent to the following: Adding the parenthesis does not change the behavior, though, it does make it easier to read. By adding these parentheses, no confusion exist about the intent of the writer. |
| Unary Operators Unary operators act on the object upon which they are called and have high precedence. (See Remarks) When used postfix, the action occurs only after the entire operation is evaluated, leading to some interesting arithmetics: RemarksOperators are listed top to bottom, in descending precedence. Operators with the same number have equal precedence and the same associativity.
The assignment, compound assignment, and ternary conditional operators are right-associative. All other binary operators are left-associative. The rules for the ternary conditional operator are a bit more complicated than simple precedence rules can express.
|
Read Article
https://develop.horje.com/learn/1434/reference