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.
void lol(hash_map<string, wordStruct>& hashofwords){
...
}
int main(){
...
lol(hashofwords);
...
return 0;
}
hmmm for some reason it's not working. Thank you for the help though!
Whats your error message?
are you using namespace std
otherwise string should be std::string
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 :(
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.