From the course: C++ Essential Training

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Operator precedence

Operator precedence - C++ Tutorial

From the course: C++ Essential Training

Operator precedence

- [Instructor] Operator precedence is the order in which operators are evaluated in an expression. This expression could have different results depending upon the order in which it is evaluated. For example, using parentheses to bind parts of the expression together. If we give precedence to the addition, we get this result, and if we move the parentheses around a bit, we get a different result. And if we remove the parentheses altogether, we get yet a different result. The order of evaluation without the parentheses is that the multiplication happens first, then the division, and then the addition. It's as if it were parenthesized like this. The point of understanding operator precedence is to be aware of the rules. You don't need to memorize the rules. There are plenty of handy reference tables available. But you do need to know that this is how it works and ultimately, if you care about the order of evaluation of…

Contents