0

I'm thinking what the output of int i = 0; cout << (i++) << (i++); is in c++11.

As my understanding, this code can be transformed into operator<<(operator<<(cout, i++), i++). Am I right?

I thought it would print 01, however, in my Ubuntu system, it printed 10.

Why? Is it an UB or not? If it's an UB, does it mean that f(g(i++), i++) is UB too? If it's not an UB, why was the output 10, instead of 01?

hanie
  • 1,863
  • 3
  • 9
  • 19
Yves
  • 11,597
  • 17
  • 83
  • 180

0 Answers0