我知道这是一个常见的问题,但是在寻找参考资料和其他材料时,我找不到这个问题的明确答案.
请考虑以下代码:
#include <string>
// ...
// in a method
std::string a = "Hello ";
std::string b = "World";
std::string c = a + b;
Run Code Online (Sandbox Code Playgroud)
编译器告诉我它找不到重载的运算符char[dim].
这是否意味着在字符串中没有+运算符?
但在几个例子中,存在类似这样的情况.如果这不是连接更多字符串的正确方法,那么最好的方法是什么?
c++ string-concatenation standard-library stdstring operator-keyword