By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,881 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

hash_set usage error

P: 4
Hello Experts,

This code is giving me some compilation error shown after the code. I wonder what am I doing wrong ? Any idea ? Thanks

hash_set<NetChannelConnectedRegion*>* nccrMasterlist;
hash_set<NetChannelConnectedRegion*>::iterator nccrIter;

for(nccrIter = nccrMasterlist.begin(); nccrIter != nccrMasterlist.end(); ++nccrIter)
{

}




/usr/include/c++/3.2.3/ext/stl_hashtable.h:586: instantiated from `__gnu_cxx::_Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>& __gnu_cxx::_Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>::operator++() [with _Val = NetChannelConnectedRegion*, _Key = NetChannelConnectedRegion*, _HashFcn = __gnu_cxx::hash<NetChannelConnectedRegion*>, _ExtractKey = std::_Identity<NetChannelConnectedRegion*>, _EqualKey = std::equal_to<NetChannelConnectedRegion*>, _Alloc = std::allocator<NetChannelConnectedRegion*>]'
../src/NetParserCmds.cpp:268: instantiated from here
/usr/include/c++/3.2.3/ext/stl_hashtable.h:517: no match for call to `(const
__gnu_cxx::hash<NetChannelConnectedRegion*>) (NetChannelConnectedRegion*
const&)'
make: *** [NetParserCmds.o] Error 1
Feb 20 '07 #1
Share this Question
Share on Google+
3 Replies


Ganon11
Expert 2.5K+
P: 3,652
Hello Experts,

This code is giving me some compilation error shown after the code. I wonder what am I doing wrong ? Any idea ? Thanks

Expand|Select|Wrap|Line Numbers
  1. hash_set<NetChannelConnectedRegion*>* nccrMasterlist; 
  2. hash_set<NetChannelConnectedRegion*>::iterator nccrIter;
  3.  
  4.     for(nccrIter = nccrMasterlist.begin(); nccrIter != nccrMasterlist.end(); ++nccrIter)
  5.        {    
  6.  
  7.        }
One problem is that nccrMasterList is a pointer to a vector, due to the * after the <NetChannelConnectedRegion*>. This, nccrMasterList has no .begin() function. You should change the for... loop to

Expand|Select|Wrap|Line Numbers
  1. for(nccrIter = nccrMasterlist->begin(); nccrIter != nccrMasterlist->end(); ++nccrIter)
  2.        {    
  3.  
  4.        }
or change nccrMasterList to an actual vector rather than a pointer.
Feb 20 '07 #2

P: 4
One problem is that nccrMasterList is a pointer to a vector, due to the * after the <NetChannelConnectedRegion*>. This, nccrMasterList has no .begin() function. You should change the for... loop to

Expand|Select|Wrap|Line Numbers
  1. for(nccrIter = nccrMasterlist->begin(); nccrIter != nccrMasterlist->end(); ++nccrIter)
  2.        {    
  3.  
  4.        }
or change nccrMasterList to an actual vector rather than a pointer.



Oops, sorry about the confusion, I made a typo.

Actually, nccrMasterList is an acutal vector as shown below.

hash_set<NetChannelConnectedRegion*> nccrMasterlist;
hash_set<NetChannelConnectedRegion*>::iterator nccrIter;

for(nccrIter = nccrMasterlist.begin(); nccrIter != nccrMasterlist.end(); ++nccrIter)
{
}

I am still having the same compilation error. Any Idea ? Thanks,
Apurva
Feb 20 '07 #3

Ganon11
Expert 2.5K+
P: 3,652
Oops, sorry about the confusion, I made a typo.
And don't ya love 'em? Don't worry about it, it happens to the best of us.

Expand|Select|Wrap|Line Numbers
  1. for(nccrIter = nccrMasterlist.begin(); nccrIter != nccrMasterlist.end(); ++nccrIter)
  2.        {
  3. }
My only guess is that, in this case, there is no pre-increment operator for an iterator, so ++nccrIter won't work. Try nccrIter++ instead and see if that will do anything, then try nccrIter = nccrIter + 1 if the post-increment operator won't work.
Feb 21 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.