使用iterator调用map中的(first)键和(second)值
作者:互联网
#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 来源: https://www.cnblogs.com/liuyanchao/p/16588548.html