previous | start | next

## Removing and Inserting Elements

- How do you remove an element from a vector?
- If the order is not important, overwrite the element to be removed with the last element of the vector, then shrink the size of the vector.

  >     void erase(vector<string>& v, int pos){
  >        int last_pos - v.size() - 1;
  >        v[pos] = v[last_pos];
  >        v.pop_back();
  >     }

previous | start | next