for(auto const& value: a) {
/* std::cout << value; ... */
}
for (int i = 0; i < Vector.size(); i++)
{
type Element = Vector[i];
}
for(int i = 0; i < vec.size(); i++){
cout << vec[i] << endl;
}
for (const auto& i : vector)
{
// do something
}
for (auto & element : vector) {
element.doSomething ();
}
vector<int> vi;
...
for(int i : vi)
cout << "i = " << i << endl;
for(std::vector<T>::size_type i = 0; i != v.size(); i++) {
v[i].doSomething();
}
// Using a for loop with iterator
for(std::vector<int>::iterator it = std::begin(v); it != std::end(v); ++it) {
std::cout << *it << "
";
}