黑马程序员C++提高8——pair【对组】

在这里插入图片描述

#include<iostream>
using namespace std;

//对组pair
void test01() {
    
    
	//构造方法
	pair<int, int> pair1(10, 20);
	cout << "pair1.first:" << pair1.first 
		 << "\tpair1.second:" << pair1.second << endl;

	pair<int, string> pair2 = make_pair(30, "aaaa");
	cout << "pair2.first:" << pair2.first
		 << "\tpair2.second:" << pair2.second << endl;

	pair<int, string> pair3 = pair2;
	cout << "pair3.first:" << pair3.first
		 << "\tpair3.second:" << pair3.second << endl;
}

int main() {
    
    
	test01();
	
	cout << endl << endl;
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_43685399/article/details/108610873