void MovieUser::AddMovie()
{
string userTitle;
cout << "\nTitle: ";
cin.ignore();
getline(cin, userTitle);
MovieRating *p = new MovieRating(userTitle);
moviesSeen.push_back(p);
for (int i=0; i < moviesSeen.size();i++)
{
if (userTitle == moviesSeen[i]->title)
{
moviesSeen.pop_back();
}
}
}
The code above of for a function that stores a movie title. i dont want it to store duplicate strings and the code i have right now will just delete every input. Thanks for the help
std::set would seem appropriate here.
If you want to keep the vector, push after checking for duplicates. Now you push a new item, find it and then pop it. Move line 10 down after 17 and change line 15 with a return.