阅读量:116
在C++中,可以使用"+"操作符来拼接字符串。例如:
#include
#include
int main() {
std::string str1 = "Hello";
std::string str2 = "World";
std::string result = str1 + " " + str2;
std::cout << result class="hljs-keyword">return 0;
}
在上面的例子中,我们使用"+"操作符将两个字符串str1和str2拼接在一起,并将结果存储在result变量中。最后,使用cout输出结果。