Hi.
I got a problem with deleting items of a vector. I did it like this:
void THIS::bashDelPerson() {
cout << "Bitte Suchstring eingeben: ";
char search[128];
cin >search;
vector<Person>::iterator iter;
iter = persons.begin();
Person* person;
while ( iter != persons.end() ) {
if ( strstr(iter->getFirstName(), search) != 0 ) {
persons.erase(iter);
}
cout << "Moep\n";
if(iter != persons.end()){iter++;}
}
}
But this implementation only works if the Person, which should be deleted is
the last one. If it is followed by another person it looks like this, if i
print out the persons:
Thats the vector i had before:
Vorname: Hans
Nachname: Wurst
Vorname: Alf
Nachname: Egel
Vorname: John
Nachname: Doe
By deleting Alf it looks like this:
Vorname: Hans
Nachname: Wurst
Vorname: àr
Nachname: °s
How can i fix it?
Regards!
Christian