The 'erase()' function in C++ is used to remove elements from a vector. It takes an iterator position as an argument, which specifies the location from where the elements are to be removed. The function returns an iterator to the element following the last element erased.

Here is an example of how the 'erase()' function can be used:

#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<int> v {1, 2, 3, 4, 5};

  // Removing element at position 2
  auto it = v.erase(v.begin() + 2);

  // Printing the modified vector
  for (auto i : v) {
    cout << i << ' ';  
  }
  cout << endl;

  // Printing the iterator returned by erase()
  cout << 'Iterator returned by erase(): ' << *it << endl;

  return 0;
}

In this example, we first create a vector 'v' with five integer elements. We then use the 'erase()' function to remove the element at position 2 (which has the value 3). The iterator returned by the 'erase()' function is then printed to the console, which in this case points to the element following the last element erased (which has the value 4). Finally, we print the modified vector to the console, which now contains the elements {1, 2, 4, 5}.

C++ Vector erase() Function: Removing Elements by Iterator