c++ - How to return an Iterator--list<T>:: iterator, as function return value -


i implementing abstract hash-table container. find() function defined , works fine, shown below:

template <class hashedobj> hashedobj& hashtable<hashedobj>::find(const hashedobj &x){     typename list<hashedobj>::iterator itr;     itr = std::find(thelist[hash(x)].begin(), thelist[hash(x)].end(), x);     if(itr == thelist[hash(x)].end())         return item_not_found;     else         return *itr; }  

however, want define function called findaddress() returns itr (the iterator) instead of *itr. code is:

typedef list<hashedobj>::iterator iterator; template <class hashedobj> iterator hashtable<hashedobj>::find(const hashedobj &x){     return std::find(thelist[hash(x)].begin(), thelist[hash(x)].end(), x); }  

the above complain that:

type std::list<hashedobj, std::allocator<_chart> > not derived type   hashedtable<hashedobj>. 

basically want return iterator type has been defined std before.

i no expert, both functions have same name in code given, while accepting same parameter. normal? also, assume mean "function called findaddress()" instead of "class called findaddress()".


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -