A two-dimension vector: (I want to go through vector and if I find the same name as "and", then delete or erase it, but why it can only work with it1 not it2? how to fix it?)
vector<Animals>numberOfAnimals(12);
vector<vector<Animals>>all(4,numberOfAnimals);
void delete_item(vector<vector<Animals>>&all,string ans)
{
for (auto it1=all.begin();it1!=all.end();it1++)
{
for (auto it2=(*it1).begin();it2!=(*it1).end();it2++)
{
if ((*it2).getter_name()==ans)
{
all.erase(it1); //no error
all.erase(it2--); //error
}
}
}
}