At this link, it is stated that
The order of evaluation of sub-expressions, including operands of operators (e.g., +, -, =, * , /) is Unspecified.
It is clear that in the expression
foo1() = foo2() = foo3() = 7; // snippet of C++ code
the operands of the =
operator can be evaluated in any order. Your compiler is free to choose (link, answered by Ralph Tandetzky).
This question may look foolish but I am really confused about this. Is the above statement also true if foo1()
, foo2()
and foo3()
are replaced by a
, b
, and c
? As in:
a = b = c = 7;