I'm facing a little problem with a searching algorithm.
This is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void deletePerson(vector<persoon> &lijst)
{
system("CLS");
string contact;
cout<<"Please enter the name of the contact you'd like to delete:\n";
getline(cin, contact);
for (vector<persoon>::iterator i = lijst.begin(); i != lijst.end(); i++)
{
if (lijst[i].getNaam() == contact)
{
lijst.erase(i);
break;
}
}
}
It should search in the vector of person classes for someone with the same name as string contact. I know lijst.erase() requires an iterator. But how can I access a member function from the class the iterator is pointing to? lijst[i].getNaam()
gives me an error...