Home › C++ Tutorial › C++ iterators
C++ iterators
Pointers into containers.
begin() and end() give iterators. Use *it for the value and ++it to move.
Example code
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> v = {4, 5, 6};
for (auto it = v.begin(); it != v.end(); ++it) cout << *it << " ";
cout << endl;
return 0;
}