char types in C ++ (and also in C) are integer types. They behave like whole types. Just like when you write 5 + 3 in your code, you expect to get integral 8 as the result (not the string "53" ), when you write c1 + c2 in your code above, you should expect to get the integral result - arithmetic sum of c1 and c2 .
If you really want to combine two characters to form a string, you have to do it differently. There are many ways to do this. For example, you can create a C style string
char str[] = { c1, c2, `\0` };
which will be implicitly converted to std::string on
return str;
Or you can immediately build std::string (which can also be done in several ways).
source share