I have tried using #include<hash_map>
and #include <hash_set>
and I still get the same errors.
Here is my code:
void HashTable_chaining::remove( const string & x )
{
int hash_index = hash( x, theLists.size( ) ) ;
list<string>& whichList = theLists[ hash_index ];
// search to make sure element not present
for(list<string>::iterator itr=whichList.begin();itr!=whichList.end();itr++) {
if(*itr==x) {
theLists[hash_index].erase(itr);
return;
}
}
// element not found - so nothing to remove
}
And my errors are:
Error 8 error C2872: 'hash' : ambiguous symbol c:\users\aaron johnson\desktop\program 5(johnson- noakes)\program 5(johnson- noakes)\chaining.cpp 32 1 Program 5(Johnson- Noakes)
And I have 8 of these errors. Any suggestions? How can I find out which headers have to be included to use hash?
Is hash a function of your own? If so, try putting it in a namespace of your own and then call the function like
int hash_index = yournamespace::hash( x, theLists.size() );
If you want to use the std::hash: It is defined in
#include <functional>
You can find the entire C++ spec here online, including our friend "std::hash":
hash_set and hash_map is available in the SGI STL. Take a look at the following pages:
The documentation and source code is available at this link:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.