可能重复:
How do I concatenate multiple C++ strings on one line?
我该怎么做:
string test1 = "Hello ";
string test2 = "World!";
并将它们连接起来制作一个字符串?
答案 0 :(得分:9)
怎么样
string test3 = test1 + test2;
或者
test1.append(test2);
答案 1 :(得分:3)
你可以这样做:
string test3 = test1 + test2;
或者如果你想添加更多的字符串文字,那么:
string test3 = test1 + test2 + " Bye bye World!"; //ok
或者,如果你想在开头添加它,那么:
string test3 = "Bye bye World!" + test1 + test2; //ok