Skip to content
Justice Tech School

Iterators

Iterators point at elements. begin and end give a range.

Example
#include <iostream>
#include <vector>

int main() {
  std::vector<int> v = {1, 2, 3};
  for (auto it = v.begin(); it != v.end(); ++it) std::cout << *it << " ";
  std::cout << "\n";
  return 0;
}

Result

1 2 3 

Exercise

Dereference.

*

Quiz Test

What does end() point to?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.