for(auto it = M.begin(); it!=M.end();it++)
{
cout<<it->first<<" "<<it->second<<"\n";
}
Run Code Online (Sandbox Code Playgroud)
上面的代码工作得很好但是,
for(auto it : M)
{
if(it->second == 1) return it->first;
}
Run Code Online (Sandbox Code Playgroud)
这给了我一个错误。
为什么我必须使用it.secondandit.first而不是it->secondand it->first?