首页 > 其他分享 >使用iterator调用map中的(first)键和(second)值

使用iterator调用map中的(first)键和(second)值

时间:2022-08-15 15:56:50浏览次数:51  
标签:map iterator second key include first

#include<iostream>
#include<string>
#include<map>
using namespace std;


int main() {
//    c++ 里面的map容器的迭代器里面 有个first 和 second,分别指向键值和数值
    map<string ,string> p;
    p["one"]="first";
    map<string,string>::iterator key=p.begin();
    string a=key->first;
    string b=key->second;
    
    cout<<a<<" "<<b;
    //输出one first
    
    system("pause");

    return 0;
}

 

标签:map,iterator,second,key,include,first
From: https://www.cnblogs.com/liuyanchao/p/16588548.html

相关文章