Explain when operands are evaluated in the logical AND, logical OR, and equality operators
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:4| Question number:4.8
All Answers
total answers (1)
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:4| Question number:4.8
total answers (1)
The logical `AND` and `OR` operators follow the _short-circuit evaluation_ strategy. Which means:
- they always evaluate their left operand before the right,
- the right operand is evaluated _if and only if_ the left operand does not determine the result.
The equality operator evaluates both the left operand and the right operand, then compares those values. The order of evaluation of the two operands is undefined.