更新时间:2022-01-13 00:18:04
我相信这是因为 []
在map中不是 const
,因为它创建具有默认值的新对,如果您寻址到不存在的对。尝试
I believe that it is because []
in map isn't const
, as it creates new pair with default value, if you address to nonexisting one. Try
void pas(const map <string, float> &mm)
{
cout<<mm.find("a")->second;
cout<<mm.find("b")->second;
}