iterator

D

Douglas Dude

template<typename T>
void foo(std::map<std::string, T>&m){
std::map<std::string, T>::iterator it=m.begin();
//do something
}

That would fail on g++ at "it"
Is there another way around to use iterator with unknown T ? Thanks
 
R

Rolf Magnus

Douglas said:
template<typename T>
void foo(std::map<std::string, T>&m){
std::map<std::string, T>::iterator it=m.begin();
//do something
}

That would fail on g++ at "it"

It's always best to paste the error message into the posting.
Is there another way around to use iterator with unknown T ?

Try:

typename std::map<std::string, T>::iterator it=m.begin();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top