Using an iterator with a vector - C++ STL

C++ examples for STL:iterator

Description

Using an iterator with a vector

Demo Code

#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;
}

Result


Related Tutorials