STL容器pair对组
时间:2021-08-29 23:09:38
收藏:0
阅读:27
1.
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> using namespace std; //创建对组 void test01() { //第一种 pair<string, int> p(string("Tom"), 100); //取值 cout << "姓名: " << p.first << " 年龄:" << p.second << endl; //第二种 pair<string, int> p2 = make_pair("Jerry", 20); cout << "姓名: " << p2.first << " 年龄:" << p2.second << endl; } int main() { test01(); system("Pause"); return 0; }
结果:

原文:https://www.cnblogs.com/yifengs/p/15193809.html
评论(0)