91: cout << “GrowingClass(3):” << endl;
92: ShowVector(GrowingClass);
93:
94: GrowingClass[0] = Harry;
95: GrowingClass[1] = Sally;
96: GrowingClass[2] = Bill;
97: cout << “GrowingClass(3) after assigning students:” << endl;
98: ShowVector(GrowingClass);
99:
100: GrowingClass.push_back(Peter);
101: cout << “GrowingClass() after added 4th student:” << endl;
102: ShowVector(GrowingClass);
103:
104: GrowingClass[0].SetName(“Harry”);
105: GrowingClass[0].SetAge(18);
106: cout << “GrowingClass() after Set\n:”;
107: ShowVector(GrowingClass);
108:
109: return 0;
110: }
111:
112: //
113: // Display vector properties
114: //
115: template<class T>
116: void ShowVector(const vector<T>& v)
117: {
118: cout << “max_size() = “ << v.max_size();
119: cout << “\tsize() = “ << v.size();
120: cout << “\tcapacity() = “ << v.capacity();
121: cout << “\t” << (v.empty()? “empty”: “not empty”);
122: cout << endl;
123:
124: for (int i = 0; i < v.size(); ++i)
125: cout << v[i] << endl;
126:
127: cout << endl;
128: }
EmptyClass:
max_size() = 214748364 size() = 0 capacity() = 0 empty
GrowingClass(3):
max_size() = 214748364 size() = 3 capacity() = 3 not empty
New Student is 16 years old
New Student is 16 years old
New Student is 16 years old
OUTPUT
698 Day 19
LISTING19.8 continued