Hi guys i'm tyring to delete some elements from a vector. I am trying to delete from 0 to k-1 and from k to the end. That means in theory that only element k should remain.

1) cell[j].erase(cell[j].begin(),k-1);
2) cell[j].erase((cell[j].begin()+k+1),(cell[j].end()));


line 2 does not give me an error, however line one gives me:

error C2664: 'std::vector<_Ty>::iterator std::vector<_Ty>::erase(std::vector<_Ty>::iterator,std::vector<_Ty>::iterator)' : cannot convert parameter 2 from 'int' to 'std::vector<_Ty>::iterator'
with
[
_Ty=int
]
and
[
_Ty=int
]
No constructor could take the source type, or constructor overload resolution was ambiguous

does anyone have any ideas? Thanks

This is because erase call expects both the parameters to be iterators while in your first line you have called the erase function with an integer argument. Make appropriate change to the second argument of your first line to an iterator and it should be fine.

*Hint: Use the same trick you used in the second line. *