Here is the code I want to use to delete any entries with values more than 2 and fewer than 5.
vector<int> myvector{3, 3, 3, 3, 3, 3, 3, 1, 2, 3, 4, 5 , 2, 3, 4, 9};
vector<int>::iterator it;
it = myvector.begin();
for(int i = 0; i < myvector.size(); i++)
{
if(myvector[i] > 2 && myvector[i] < 5)
{
myvector.erase(it+i);
}
}
for(int i = 0; i < myvector.size(); i++)
{
cout << ' ' << myvector[i];
}
output: 3 3 3 1 2 4 5 2 4 9
Where is the problem.