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;
}

猜你喜欢

转载自www.cnblogs.com/xpylovely/p/12204255.html