Erasing element in 2d vector?

I want to delete an element in a 2d vector, say [1][1] in "Field", which is a 4x5 vector

I tried
Field.erase([1][1]);

I know that for a 1d vector, I would just do
Field.erase (Field.begin()+1)

but what about for 2d vectors?
Last edited on
 
Field[1].erase(Field[1].begin()+1);


vectors will get strange if you start "embedding" them in each other, they were only designed for 1d use.
Also note that the above will only remove the element from Field[1].

Field[0], Field[2], etc will still have all 4 (5?) elements. So you wouldn't have a clean grid anymore, you'd have a jagged 2D array.
Last edited on
Topic archived. No new replies allowed.