c++ loop through vector reference code example Example: iterate over vector in c++ for (auto & element : vector) { element.doSomething (); }