Caffeinated Coder
Book an appointment
Lesson 20 · Modern C++

Iterators and algorithms

An iterator marks one position in a container: *it reads the element there and ++it moves on. Two of them, begin() and end(), describe a range, and every standard algorithm works on a range instead of on a container. Walk an iterator along a five-element vector by hand, then watch std::find, std::sort and std::count do the same walk for you, see why "not found" means end(), why sort moves values but not iterators, and how growing a vector can leave old iterators pointing at nothing.

12 min10 steps5 questionsAdvanced
Fig 20 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.