    01: #include <iostream>
    02: #include <string>
    03: #include <vector>
    04:
    05: using namespace std;
    06:
    07: /**
    08:    Removes an element from an ordered 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:    for (int i = pos; i < v.size() - 1; i++)
    15:       v[i] = v[i + 1];
    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] = "Cracker, Carl";
    33:    staff[1] = "Hacker, Harry";
    34:    staff[2] = "Lam, Larry";
    35:    staff[3] = "Reindeer, Rudolf";
    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: }