0

Consider

auto a = 0;
std::cout << a;
std::cout << a++;
std::cout << ++a;
std::cout << std::endl;

Output: 002

Which is expected regarding the post and pre incrementation rule.

However the following code

auto a = 0;
std::cout << a << a++ << ++a << std::endl;

Output: 212

Since the following seems to print number in the right order

auto a = 0;
auto b = 1;
auto c = 2;
std::cout << a << b << c << std::endl;

Output: 012

I am trying to figure out why I got 212 in the second case?

Full code is here: https://ideone.com/IUiFb6

scoulomb
  • 560
  • 1
  • 5
  • 18

0 Answers0