hash - Removing item from list in c++ -
hello writing code hash table , want right delete function deletion of string values in list.
void hash::remove(string word) { int i,flag=0; list<string>::iterator it; for(i=0;i<10;i++) { for(it=hashtable[i].begin();it!=hashtable[i].end();it++) { if(word==*it){ hashtable.erase(it); break; } } } }
but when compile got error: error: request member ‘erase’ in ‘((hash*)this)->hash::hashtable’, of non-class type ‘std::list > [10]’
i cannot understand this. please me .
use hashtable[i].erase(it)
instead of hashtable.erase(it)
.
Comments
Post a Comment