Because it’s interpreting 010
as a number in octal format. And in a base-8 system, the number 10
is equal to the number 8
in base-10 (our standard counting system).
More generally, in the world of C++, prefixing an integer literal with 0
specifies an octal literal, so the compiler is behaving exactly as expected.