BZ易风

导航

 

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;
}

结果:

 

posted on 2021-08-27 15:00  BZ易风  阅读(26)  评论(0编辑  收藏  举报