PDA

View Full Version : map iterator



Danii
December 31st, 2006, 08:15 AM
template<class S, class T>
void StdDate<S,T>::empty()
{
std::map<S,T>::iterator it;
}


that piece of code wont work, ive been googling for hours but can't find an answer.. compiler says:

-error: expected `;' before 'it'
-error: dependent-name 'std::map<S,T,std::less<_Key>,std::
allocator<std::pair<const _Key, _Tp> > >::iterator' is parsed as a non-
type, but instantiation yields a type

if i switch it it std::map<int,int>::iterator it; it works fine, but tht was just done for testing to see if the syntax was wrong.. so why can't i use S and T?

kirupa
December 31st, 2006, 12:05 PM
Just to clarify, what language is it? C#?

Danii
December 31st, 2006, 12:34 PM
c++

MTsoul
December 31st, 2006, 02:50 PM
Did you use a namespace? The C++ compiler complains a lot about those.

Danii
December 31st, 2006, 08:08 PM
no, but the problem is solved, solution was actually given by the compiler, guess im just too lazy to read all tht output it gives..
anyways, for those who wonders the solution was to write


typename std::map<S,T>::iterator it;