下面的代码:
#include <iostream>
#include <string>
using namespace std;
int main() {
string s1 = "hello";
string s2 = "my";
string s3 = "world";
string s4;
s4 = move(s1) + move(s2) + move(s3);
cout << "s4(" << s4 << ") = s1(" << s1 << ") + s2(" << s2 << ") + s3(" << s3 << ")"<< endl;
}
给出以下输出:
s4(hellomyworld) = s1() + s2(my) + s3(world)
你能解释一下发生了什么吗?(使用 XCode 4.6.1 测试)
编辑:我希望看到:
s4(hellomyworld) = s1() + s2() + s3()