0

Anyone know how to pass an entire hashmap to a function?? The hashmap is

hash_map<string, wordStruct> hashofwords;

wordStruct contains information about each word in the hashmap.

3
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by launic
0
void lol(hash_map<string, wordStruct>& hashofwords){
...
}
int main(){
...
lol(hashofwords);
...
return 0;
}
0

hmmm for some reason it's not working. Thank you for the help though!

0

I am using namespace std;

My error is:

hashmap.cpp: In member function ‘void HashClass::setToStruct(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)’:
hashmap.cpp:166: error: no matching function for call to ‘HashClass::printOutForK(wordHash&)’
hashmap.h:51: note: candidates are: void HashClass::printOutForK(__gnu_cxx::hash_map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, wordData, __gnu_cxx::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<wordData> >&)
make: *** [hashmap.o] Error 1

but I've double checked a million times and both the prototype, and the function are the same. And the call matches also. I have no clue what's wrong :(

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.