Append multiple chars to string in C++

  append, c++, concatenation, string

Using + is a valid way to append a char to a string in C++ like so:

string s = "";
s += 'a';

However,

string s = "";
s += 'a' + 'b';

gives a warning: implicit conversion from 'int' to 'char' changes value and does not append a and b characters.

Why does the first example append the char and the second does not?

Source: Windows Questions C++

LEAVE A COMMENT