#define __MINMAX_DEFINED // use STL's generic min and max templates #include "vector.h" // include STL vector implementation #include void main (void) { vector v(5); // define a vector of int and // reserve memory for five elements for (int i = 0; i < 5; i++) v[i] = 2*i; // store arbitrary values into v[0] to v[4] cout << "Five values stored in a vector are written to cout:" << endl; for (i = 0; i < 5; i++) cout << v[i] << " "; // print values to cout cout << endl; // of course you can also use iterators // define an iterator to the first vector element vector::iterator first = v.begin(); // define an iterator past the last vector element vector::iterator last = v.end(); cout << "Now the output loop works with iterators:" << endl; while (first != last) cout << *first++ << " "; // first the iterator is dereferenced, // then it is incremented }