class - Removing an object from a structure C++ -


i ran little problem. trying through structure, find object did not meet requirements, , delete it.

but "program stopped working" after executing method.. can guys help?

void mystruct::obremove(int n) {  (mystruct *d = p; d != null; d = d->sek){     if (d->m < n){         ;     }     else{         mystruct *m=d;         d = m->sek;         delete m;      }   } } 

the m object of class, , structure containter struct. if need additional code tell, i'm waiting right here.

this structure class(note: names aren't similar trying make in english, rewriting take paste in lang.)

 struct mazgas { private: muziejus m; mazgas *sek; mazgas *p; mazgas *d; public: mazgas() : p(null), d(null) {} ~mazgas() { naikinti(); } void naikinti(); void deti(muziejus m); void imti(muziejus &m) {     m = d->m; }; void rikiuoti(); void salinti(int n); void pradzia(){ d = p; } void sekantis() { if (d) d = d->sek; } bool yra() { return d != null; } }; 

in else case, moving next item in linked list twice (once via d = m->sek;, , once via d = d->sek). can lead issue when reach end of linked list (if m->sek null, d->sek try dereference null).


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -