string::swap

void swap (string& x, string& y);

#include <iostream>
#include <string.h>

using namespace std;

int main()
{
string buyer("money");
string seller("goods");
cout << "buyer has " << buyer << endl;
cout << "seller has " << seller << endl;
swap(buyer, seller);
cout << "buyer has " << buyer << endl;
cout << "seller has " << seller << endl;
return 0;
}

posted @ 2020-01-17 09:22  MoonXu  阅读(328)  评论(0编辑  收藏  举报