map<char, int> counter;
//some code...
map<char, int>::iterator iter;
for (i = 0; i<26; i++)
{
for (iter = counter[i].begin(); iter != counter[i].end(); iter++) //error occurs
{
cout << (*iter).first << " - " << (*iter).second << endl;
}
}
我不确定此错误消息的含义: *error: request for member âbeginâ in âcounter.std::map<_Key, _Tp , _Compare, _Alloc>::operator[] [with _Key = char, _Tp = int, _Compare = std::less, _Alloc = std::allocator >, std::map<_Key, __Tp, _Compare, _Alloc>::mapped_type = int, std::map<_Key, _Tp, _Compare, _Alloc>::key_type = char]((* &((std::map::key_type)j)))â,属于非类* *type âstd::map::mapped_type {aka int}â*