Because he interprets 010 as an octal number . And in the base-8 system, the number 10 is equal to the number 8 in the base-10 system (our standard counting system).
In general, in the C ++ world, the prefix of an integer literal with 0 indicates an octal literal, so the compiler behaves exactly as expected.
source share