c++ how to traverse a vector code example
Example 1: c++ vector iterator
#include <iostream>
#include <vector>
using namespace std;
vector<int> myvector;
for (vector<int>::iterator it = myvector.begin();
it != myvector.end();
++it)
cout << ' ' << *it;
cout << '\n';
Example 2: c++ looping through a vector
for(std::vector<T>::size_type i = 0; i != v.size(); i++) {
v[i].doSomething();
}