Order of executions in C++ streams
Posted
by
Krzysztof Bzowski
on Programmers
See other posts from Programmers
or by Krzysztof Bzowski
Published on 2012-11-29T14:02:24Z
Indexed on
2012/11/29
17:17 UTC
Read the original article
Hit count: 183
c++
It is obvious that first cout prints 7 7 but why the second one prints 8 8 7 ? Why not 7 8 8? How does such constructions work in c++?
int ink(int *x){
*x += 1;
return *x;
}
int main(){
int *a;
int b = 6;
a = &b;
cout << ++b << " " << b << endl;
cout << b << " " << ink(a) << " " << b;
return 0;
}
© Programmers or respective owner