+ 5

can you explaine me why the resulte is 1211

#include <iostream> using namespace std; int main() { int x=10; int &y=x; y++; cout << x << y++; return 0; }

9th Feb 2017, 4:11 PM
L Boudhar
L Boudhar - avatar
2 Respuestas
+ 2
yeah it acts backwards. Try this: int x = 0; std::cout << x++ << x++ << x++; You'll get 210. Funny thing std::cout << ++x << ++x << ++x; will print 333
9th Feb 2017, 4:26 PM
Zilvinas Steckevicius
Zilvinas Steckevicius - avatar
0
I think because cout using Insertion operator so that instructions work from right to left such that y++ run first then Value of y is Printed then Increased the value at y ( as using post increment) then print x ! ..
9th Feb 2017, 4:23 PM
Shreyance Gupta
Shreyance Gupta - avatar