Possible Duplicate:
cout << order of call to functions it prints?
Undefined Behavior and Sequence Points
Why does this code print 2 1 0?
#include <iostream>
struct A{
int p;
A():p(0){}
int get(){
return p++;
}
};
int main(){
A a;
std::cout<<a.get()<<" "<<a.get()<<" "<<a.get()<<std::endl;
}
As I stated in my comment, there’s no sequence point…
According to §6.2.2 of Stroustrup’s The C++ Programming Language, Third Edition…
§5.4 of the C++03 standard specifies:
You can learn more about sequence points and undefined behavior here.