// demonstrates using typedef to shorten vector and iterator declarations // Mikhail Nesterenko // 4/2/2012 #include #include using std::cin; using std::cout; using std::endl; using std::vector; typedef vector intVector; // gives a shorter name to vector of integers typedef intVector::iterator intVectorIterator; // and to iterator over this vector int main(){ intVector v(5); // declaring a vector of integers // manipulating vector as array cout << "Enter 5 integers: "; for(int i=0; i<5; ++i){ int num; cin >> num; v[i]=num; } // manipulating vector using iterators cout << "Your numbers: "; for(intVectorIterator ip=v.begin(); // note the iterator declaraion ip != v.end(); ++ip){ cout << *ip << " "; } cout << endl; }