Let's say I have a std::vector<int> v
which is filled with some numbers:
{0, 1, 2, 3}
Now, let's say I get an iterator pointing to the number 2
with v.begin()+2
and save it inside a variable. At this point if I insert another number between 1 and 2, and my vector will look like
{0, 1, 4, 2, 3}
does my iterator still pointing to the 2 (which has moved a cell forward) or it's pointing at the new number (4)? If so, is it possible to get a pointer which follows its element if it's moved?
EDIT:
Ok, my first question may have an answer, but I do not understand why it was marked as a duplicate since I asked something else too...