++a immediately increases a by 1 before giving its value to std::cout.
a++ gives its current value to std::cout first for outputing before it increases its value by 1.
++a immediately increases a by 1 before giving its value to std::cout.
a++ gives its current value to std::cout first for outputing before it increases its value by 1.
There is absolutely ZERO guarantee that the operators will be evaluated in the order you think they will be. Doing multiple increments in a std::cout statement might not evaluate to "5 7 8."
The ONLY guarantee is the final value after the std::cout will be 8 something undefined.
There is absolutely ZERO guarantee that the operators will be evaluated in the order you think they will be. Doing multiple increments in a std::cout statement might not evaluate to "5 7 8."
The ONLY guarantee is the final value after the std::cout will be 8 something undefined.
That's crazy! Why is it so unorderly? What happened to order of operations?