#include <iostream>
#include <vector>
int main ()
{
using namespace std;
vector <int> v;
v.push_back (50);
v.push_back (1);
v.push_back (987);
v.push_back (1001);
// Access objects in a vector using iterators:
vector<int>::iterator i = v.begin();
while (i != v.end ())
{
size_t nElementIndex = distance (v.begin (),
i);
cout << "Element at position ";
cout << nElementIndex << " is: " << *i << endl;
// move to the next element
++ i;
}
return 0;
}