示例:
#include<iostream>
using namespace std;
void test01()
{
pair<string, int> p("Tom", 20);
cout << "姓名为:" << p.first << " 年龄为:" << p.second << endl;
pair<string, int>p2 = make_pair("Jerry", 34);
cout << "姓名为:" << p2.first << " 年龄为:" << p2.second << endl;
}
int main()
{
test01();
return 0;
}
总结:两种方法都可以创建队组,掌握一种就可以;