内容
pair的基本概念及构建方式。
运行代码
#include <iostream>
#include <string>using namespace std;void test01()
{// pair将2个数据组合成一组数据来使用(first 、second)// 注意pair的使用可以不添加头文件pair<string, int> p1("Tom", 11); // 构建方式01cout << p1.first << " " << p1.second << endl;pair<string, int> p2 = make_pair("Jerry", 22); // 构建方式02cout << p2.first << " " << p2.second << endl;
}int main()
{test01();return 0;
}