Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Error defining HashMap::iterator type, please help

Reply
Thread Tools

Error defining HashMap::iterator type, please help

 
 
michaelmei michaelmei is offline
Junior Member
Join Date: Oct 2006
Posts: 3
 
      10-08-2006
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 by michaelmei; 10-08-2006 at 01:39 PM..
Reply With Quote
 
 
 
 
michaelmei michaelmei is offline
Junior Member
Join Date: Oct 2006
Posts: 3
 
      10-09-2006
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!
 
Reply With Quote
 
 
 
 
michaelmei michaelmei is offline
Junior Member
Join Date: Oct 2006
Posts: 3
 
      10-09-2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error defining UI_need help urgently Atul Dongargaonkar Ruby 3 10-06-2010 06:47 PM
defining or not defining destructors johny smith C++ 8 07-02-2004 08:51 AM
HELP! HELP! PLEASE, PLEASE, PLEASE tpg comcntr Computer Support 11 02-15-2004 06:22 PM
Error while defining char array Boogie El Aceitoso C++ 6 12-03-2003 07:51 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57