cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Evaluation ostream
Evaluation ostream
Mar 18, 2014 at 9:54pm UTC
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?
Mar 18, 2014 at 10:43pm UTC
ne555
(10692)
the order of evaluation of the
parameters
is unspecified.
a nice reading
http://herbsutter.com/gotw/_102/
Mar 18, 2014 at 11:21pm UTC
Yanson
(885)
How is it unspecified? the ++ operator has higher precedence than the << operator so I is incremented first. Am I wrong?
Mar 19, 2014 at 1:59am UTC
ne555
(10692)
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
Mar 19, 2014 at 2:03am UTC
Mar 19, 2014 at 9:44pm UTC
closed account (
EwCjE3v7
)
Thanks I gt it now :)
Topic archived. No new replies allowed.