64,687
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <string>
#include <iostream>
using namespace std;
void swap(string s1, string s2);
int main(int argc, char **argv) {
string s1 = "s1";
string s2 = "s2";
cout << 111 << endl;
swap(s1, s2);
cout << s1 << endl;
cout << s2 << endl;
}
void swap(string s1, string s2) {
string tmp = s1;
s1 = s2;
s2 = tmp;
cout << s1 << endl;
cout << s2 << endl;
}