c++ - how to get the STL list which is stored in a STL array? -


i'm trying making hash table stl array , list . in header file it's defined

              typedef std::list<bike*> bikeptrlist; 

and 2 classes :

class bikehashtableadt : public std::array< bikeptrlist, 256 > class bikehashtableimp : public bikehashtableadt 

i'd store " bike* " in list , , store lists in array. in cpp file call function

void bikehashtableimp::addbikeptr(bike* ptr) {     int hashint = hashfun(ubptr->license); // integer returned hash function       bikeptrlist &tmp=(*this)[hashint];  // "this" means class bikehashtableimp     std::list<bike*> tmp.push_back(ptr);     (*this)[hashint]=tmp;              } 

there run-time error , every time function called , new bike* ptr push_back list , prior data stored in list covered. tell me what's wrong code ?

this line:

std::list<bike*> tmp.push_back(ptr); 

is wierd. std::list doesn't belong there. did mean write

tmp.push_back(ptr); 

?

and line

(*this)[hashint]=tmp;   

also appears unneeded. tmp same (*this)[hashint].


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -