code :
#include <iostream>
using namespace std;
int main()
{
auto pair_1 =make_pair(1,"2");
cout << pair_1.first << endl;
cout << pair_1.second << endl;
auto pair_2 = make_pair(2, "1");
pair_1.swap(pair_2); //交换
cout << pair_1.first << endl;
cout << pair_1.second << endl;
cout << pair_2.first << endl;
cout << pair_2.second << endl;
}
运行结果:
标签:std,cout,auto,make,简单,pair,main From: https://blog.51cto.com/u_15906863/5978177