c++ (数据类型 && 对组)

对组 (不需要头文件的)

//创建对组
void test02()
{
	//第一种
	pair<string, int> p(string("Tom"), 100);
	cout << "姓名: " << p.first << endl;
	cout << "年龄:" << p.second << endl;
	//第二种
	pair<string, int> p2 = make_pair("Jerry", 200);
	cout << "姓名: " << p2.first << endl;
	cout << "年龄:" << p2.second << endl;
}

posted on 2021-04-28 14:59  lodger47  阅读(112)  评论(0)    收藏  举报

导航