I have a list of objects and I want to delete a certain object once it hits the if condition. But I am having issues with it working. Mostly because the if condition is throwing the error.
Also I don't know if I need to create a temp folder value and let that be my if condition? I'm honestly kind of confused on iterators and any extra information might be helpful.
void removeFolder(string fName)
{
list<Folder> folders = this->getFolders();
for (list<Folder> itr = folders.begin(); itr != folders.end();)
{
if (fName == *itr)
itr = folders.erase(itr);
else
++itr;
}
}