我正在使用里面有pair的 map , 但无法弄清楚如何使用 map 迭代器进行访问
我的 map 声明
map<ll,pair<ll,ll> > val;
map<ll,pair<ll,ll> > ::iterator it;
我用来访问插入值的是
cout<<it->first<<" " <<it->second->first<<" " <<it->second->second<<endl;
但编译器显示此错误
error: base operand of '->' has non-pointer type 'std::pair<long long unsigned int, long long unsigned int>'|
最佳答案
使用.
访问一对元素。
cout<<it->first<<" " <<it->second.first<<" " <<it->second.second<<endl;
关于c++ - 如何访问其中有一对的 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42184477/