Evaluation ostream

closed account (EwCjE3v7)
My book says that the ++I might be emulated before I is printed.
I don't understand. Would it not go left to right?


 
  cout << I << " " << ++I << endl

Like if I wrote this
cout << "hi" << "bye" << endl
It would print out hi before bye all the time right?
the order of evaluation of the parameters is unspecified.
a nice reading http://herbsutter.com/gotw/_102/
How is it unspecified? the ++ operator has higher precedence than the << operator so I is incremented first. Am I wrong?
First you confuse it with associativity, now with precedence.
the idea is that you do not know which operand is resolved first

please bother yourself to follow the link http://en.cppreference.com/w/cpp/language/eval_order
Last edited on
closed account (EwCjE3v7)
Thanks I gt it now :)
Topic archived. No new replies allowed.