Answer 1:
When using short-circuiting operators (&& and || as opposed to bitwise & and |), evaluation stops once the result is determined. And with logical operators, C++ evaluates from left to right. This means that in the example of a && b && c, evaluation could stop at a, at b, or require evaluating and comparing all three a, b, and c. However, it won't check b && c before evaluating a.
(References - cplusplus midway down page , cppreference: Rule #6)
Click Here to return to the search form.
|