The order of evaluation of the arguments to cout is not defined by the C++ language standard. In other words, you cannot be assured that just because you have placed a variable in the left most position

The order of evaluation of the arguments to cout is not defined by the C++ language standard. In other words, you cannot be assured that just because you have placed a variable in the left most position in the statement, that it will get evaluated in any particular order.

BTW, it appears in your example above that the order of evaluation is from right to left. This makes the right most i = 1, the middle one is also = 1, it is then incremented and then the left most i is now = 2.

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

>>order of evaluation of the arguments to cout is not defined by the C++ language standard
This has nothing to do with the cout. it has to do with the order of evaluation of operands in an expression and it IS defined by the standard. This will work the same on all C++ compilers (assuming they don't have a bug). This will work with the >> operator in all cases.

The order in which subexpressions are evaluated is implimentation defined (except with "," ,"&&", and "||"). You are guarranteed that the << operators are called in left to right order, but the values that are passed to them might not be.

You are guaranteed that the order of evaluation of the << operators is

(cout << i) << i++

but you are not guarantted the order in which the i and i++ subexpressions are calculated. The only guarantee that you get is that the second call to operator << will have the value of i before it was ++ed there is no guarantee that the ++ is done after the call to the 2nd operator <<, what's mroe there is no guarantee that is done after the call to the 1st!

0

Featured Post

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples. You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects.
A brief on problem:
Lets take example problem for simplicity:
- I have a G…

The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.