C++ examples for STL:iterator
Using an iterator with a vector
#include <cinttypes> #include <iostream> #include <vector> using namespace std; int main(int arcg, char* argv[]) { using IntVector = vector<int32_t>; using IntVectorIterator = IntVector::iterator; IntVector myVector{ 0, 1, 2, 3, 4 }; for (IntVectorIterator iter = myVector.begin(); iter != myVector.end(); ++iter) {/*from w w w . j a v a 2s . co m*/ cout << "The value is: " << *iter << endl; } return 0; }