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