For some reason this code is not accepted by the compiler.
template<class T, class A>
void ShowMap(const map<T, A>& v)
{
for (map<T, A> ::const_iterator ci = v.begin();ci != v.end(); ++ci)
cout << ci ->first <<": " << ci ->second <<endl;
cout << endl;
}
The compiler says:
main.cpp:103: error: expected `;' before ‘int’
main.cpp:103: error: ‘ci’ was not declared in this scope
main.cpp:91: instantiated from here
main.cpp:103: error: dependent-name ‘std::map<T,A,std::less<_Key>,std::allocator<std::pair<const _Key, _Tp> > >::const_iterator’ is parsed as a non-type, but instantiation yields a type
main.cpp:103: note: say ‘typename std::map<T,A,std::less<_Key>,std::allocator<std::pair<const _Key, _Tp> > >::const_iterator’ if a type is meant
:: === Build finished: 5 errors, 0 warnings ===
Perhaps it doesn't like setting the itterator variable to v.begin()????
Thanks for any insights!