Here is the other code. You'll see it is completely identical!!! but it produces the output "first second third".
I woke up at 4 am, and understood why both answers are possible (but not quite why my vc++ chooses between them randomly).
Consider this simpler program:
//<s>cout << "second ";</s>
return "third ";
As always, the things in cout must be printed
in left to right order, so it must be "first third".
But there is no rule about the order that they are calculated
. So the program can calculate the return value of the function before or after figuring that "first " is a text string.
But it must print them in the correct order.
Unfortunately, the actual function that I used has an extra cout in the body. This will be executed when the calculations are done. And as I've said either order of calculation is legal.
...And the correct way of saying that my function has something going on in the body of it is "the function has a side effect"
I must credit two guys on usenet for helping me with this...
I didn't understand what they were saying, but my subconscious must've figured it out!
Here's my other code. You'll see it's no different
using namespace std;
cout << "second ";
I'll email you.