Error defining HashMap::iterator type, please help

Joined
Oct 8, 2006
Messages
3
Reaction score
0
the main program:

----------------------------------------------
include <hash_map>

template<class A, class B>
class HashMapTest
{
public:
typedef hash_map<A, B> hashMap; //fine!!
typedef hash_map<A, B>::const_iterator hashMapIter;
/*GNU g++ compiler complains the hash_map<std::string, std::string>::const_iterator is not derived from class HashMapTest. Don't know what it exactly means... */

};

--------------------------------------------------

I really dont know what is wrong with the const iterator for hash_map. Can anyone correct this code fragment?
I am kinda stuck here...

Thanks in advance.
 
Last edited:
Joined
Oct 8, 2006
Messages
3
Reaction score
0
the hash_map is under the namespace __gnu_cxx

so

that is:
typedef __gnu_cxx::hash_map<K, T> dict;
typedef __gnu_cxx::hash_map<K, T>::const_iterator dict_iter;

can anyone pls help? Can't fix it now!
 
Joined
Oct 8, 2006
Messages
3
Reaction score
0
I think it is a type problem,
if I use

typedef hash_map<string, string>::const_iterator hm_iter;

it compiles fine. But is there any way I can define an iterator type of a customized hash_map Key and Value (hash_map<K, T>::iterator)?

Please help
 

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,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top