So, I am trying to get an iterator to a map that I am passing in as a const reference to a function. My compiler complains when I do something like this:
bool func(string s, const map<char, int>& m){
std::map<char, int>::iterator it = m.begin();
/*more code here...*/
}
How should I do this?
The error message is:
error: no viable conversion from 'const_iterator' (aka '__map_const_iterator<typename __base::const_iterator>') to 'std::map<char, int>::iterator'
(aka '__map_iterator<typename __base::iterator>')
std::map<char, int>::iterator it = m.begin();