It will make more sense if you write it out:
hello + ", world" + "!";
looks like this:
operator+(operator+(hello, ", world"), "!");
While
"Hello" + ", world" + exclam
looks like this
operator+(operator+("Hello" , ", world"), exclam);
Since there is no operator+
that takes two const char
arrays, the code fails.
However, there is no need for one, as you could concatenate them like the following (note I just removed the +
sign):
const string msg = "Hello" ", world" + exclam