【发布时间】:2020-05-14 21:21:17
【问题描述】:
for(auto it = M.begin(); it!=M.end();it++)
{
cout<<it->first<<" "<<it->second<<"\n";
}
上面的代码工作得很好 但是,
for(auto it : M)
{
if(it->second == 1) return it->first;
}
这给了我一个错误。
为什么我必须使用it.second 和it.first 而不是it->second 和it->first?
【问题讨论】: