It's tough to tell exactly what you are trying to do from your posts. Your original post talks about deleting columns, but your example actually deletes the second row. The code you posted doesn't look like it'll do either, but looks more like you actually are trying to delete a given column. So, here's some sample code for both:
thanks jRaskell,
deleting a row was working great but how to delete some random number of rows it means not delete just one of rows.
delete given index numbers of rows?
Erase will work with a contiguous range of entries (rows).
Erase also returns an iterator to the next element in the vector after the element that was just erased. So if you have some random criteria defined, you could just put that criteria in your while loop something like:
1 2 3 4 5 6 7 8 9 10
vector<vector<int> >::iterator row = k.begin();
while(row != k.end()){
switch((*row)[0]){
case 2:
case 4:
row = k.erase(row);
default:
row++;
}
}
The switch is for illustration only. Just note that when you call erase, you assign the return to your row iterator, and you only increment the iterator when you don't erase (because erase is incrementing the iterator for you).