1.pair类型的定义
pair<int, double> p1(1, 2.4); //用给定值初始化
pair<int, double> p2(p1); //拷贝构造函数
pair<int, double> p3; //使用默认构造函数
p3 = make_pair(1, 1.2); //利用make_pair赋值
pair<int, double> p4; //使用默认构造函数
p3 = {1,2.1}; //使用{}
pair<int, double> p5; //给first和second赋值
p5.first = 1;
p5.second = 2.5;
2.访问
cout << p5.first << " " << p5.second << endl;
//1 2.5
// c++17 structured bindings of auto
auto [x, y] = p5;
cout << x << " " << y << endl;
//1 2.5