enhanced for loop for a vector c++ code example
Example 1: iterate over vector in c++
for (auto & element : vector) {
element.doSomething ();
}
Example 2: c++ looping through a vector
for(std::vector<T>::size_type i = 0; i != v.size(); i++) {
v[i].doSomething();
}