    01: #include <iostream>
    02: #include <string>
    03: #include <vector>
    04:
    05: using namespace std;
    06:
    07: /**
    08:    Removes an element from an unordered vector.
    09:    @param v a vector
    10:    @param pos the position of the element to erase
    11: */
    12: void erase(vector<string>& v, int pos)
    13: {
    14:    int last_pos = v.size() - 1;
    15:    v[pos] = v[last_pos];
    16:    v.pop_back();
    17: }
    18:
    19: /**
    20:    Prints all elements in a vector.
    21:    @param v the vector to print
    22: */
    23: void print(vector<string> v)
    24: {
    25:    for (int i = 0; i < v.size(); i++)
    26:       cout << "[" << i << "] " << v[i] << "\n";
    27: }
    28:
    29: int main()
    30: {
    31:    vector<string> staff(5);
    32:    staff[0] = "Hacker, Harry";
    33:    staff[1] = "Reindeer, Rudolf";
    34:    staff[2] = "Cracker, Carl";
    35:    staff[3] = "Lam, Larry";
    36:    staff[4] = "Sandman, Susan";
    37:    print(staff);
    38:
    39:    int pos;
    40:    cout << "Remove which element? ";
    41:    cin >> pos;
    42:
    43:    erase(staff, pos);
    44:    print(staff);
    45:    return 0;
    46: }