"ab"
is a const char *
. 'c'
is a char
. My guess is that 'c'
is converted to an integer, said integer is added to the address of "ab"
, and the resulting pointer is passed to std::string
's constructor. You're lucky it's not miserably crashing.
See the other answers for how to do the concatenation properly.