In C++, the equality operator's associativity is left to right, as stated here and here and the returned value of an assignment operation is the value assigned to the given variable. (As shown here, here, here, and here, (section 6.5.16, pages 101-104 for the last link).)
According to this information, this:
double d = 5;
if (d == (d = 6))
cout << "but d was 5...!!!" << endl;
else
cout << "5!=6 :)" << endl;
should print "5!=6 :)"
since the expression, (d == (d = 6))
is equivalent to (5 == (6))
(which is false), but instead, "but d was 5..."
is printed. Can anyone explain why?