Showing posts with label Comment on A quick poll about order of evaluation… by dorianmuthig. Show all posts
Showing posts with label Comment on A quick poll about order of evaluation… by dorianmuthig. Show all posts

Wednesday, January 21, 2015

Comment on A quick poll about order of evaluation… by dorianmuthig

 
 

Comment on A quick poll about order of evaluation… by Bill Lynch

There’s also the question if `i == 2` at the end of that expression.

Read More »

Comment on A quick poll about order of evaluation… by dorianmuthig

Code should be evaluated left to right when piped (multiple times), reduced on both sides before assigned from the right side and evaluated one line after the other in order. Therefore the correct behavior should be:
std::vector v = { 0, 0 };  int i = 0;
There is nothing suspicious here, yet.
v[i++] = i++;
This should make
v[1] = 1;
or
v = { 0, 1 };
And then
std::cout << v[0] << v[1] << endl;
would print [quote]01[/quote] to the console.

Read More »

Comment on A quick poll about order of evaluation… by dorianmuthig

But after line three has been evaluated, i would be 2, a curiosity this poll question does not touch on.

Read More »

Comment on A quick poll about order of evaluation… by dorianmuthig

Scratch that, was thinking of ++i, should print 00, it’s messed up anyhow, who would do that? Why count it twice?

Read More »