I have the following code.
template<class key,class val>
bool has_key(key chkey,std::map<key,val> map){
for (std::map<key,val>::iterator it = map.begin(); #line 13 referenced by gcc
it!=map.end(); ++it){
if(chkey == it->first) return true;
}
return false;
}
GCC is giving me the following error.
objects.hpp: In function `bool has_key(key, std::map<key, val, std::less<_Key>,
std::allocator<std::pair<const _Key, _Tp> > >)':
objects.hpp:13: error: expected `;' before "it"
objects.hpp:14: error: `it' was not declared in this scope
Somehow "it" is not being initialized, what in Sam Hain is going on here?!
See Question&Answers more detail:os