PDA

View Full Version : map iterator


Danii
12-31-2006, 07: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
12-31-2006, 11:05 AM
Just to clarify, what language is it? C#?

Danii
12-31-2006, 11:34 AM
c++

MTsoul
12-31-2006, 01:50 PM
Did you use a namespace? The C++ compiler complains a lot about those.

Danii
12-31-2006, 07: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;