Better not to assume the order of evaluation in a C++ subexpressions. Also do not use ++ and -- operators as part of subexpressions (Eg: n + (++n))
Guaranteed order: Subexpressions using AND(&&) OR(||) and COMMA(,) operators are always evaluated in left-to-right manner. Helps with "Short-circuit evaluation" for relational operators!
General order:
Unary operator: right-to-left
Assignment: right-to-left Eg: a = b = c; OR a = (b = c);
Binary operator: left-to-right
No comments:
Post a Comment