Learn about the iterator, a template class that acts a lot like a pointer and is used to access elements of a container.
- [Instructor] An iterator is an STL object…that can iterate through the elements of a container.…An iterator acts a lot like a pointer.…It can be incremented and de-referenced…as if it were a pointer.…Here I have a working copy of iterator.cpp…from chapter three of the exercise files.…I've defined a vector of ints and I've defined…an iterator it1.…The iterator class is defined in the scope…of the container class.…So, it's accessed using the scope resolution operator…or the double colons that we've seen elsewhere.…
It's technically called a scope resolution operator.…And the type of iterator is bound to the type of the class.…And so in this case we have a vector int iterator.…So, this type of iterator will only work…with a vector of ints.…It won't work with any other class or templated class.…Begin and end iterators are generally available…from the begin and end member functions.…And so in this case, I've taken an iterator…for the begin position and an iterator for the end position.…
They're exactly the same type as you can see here…
- Template fundamentals
- STL containers
- Accessing iterators
- Output, forward, and bidirectional iterators
- The transform function
- Transforming strings and types
- Arithmetic, relational, and logical functions
- STL algorithms
Skill Level Intermediate
2. STL Containers
3. STL Iterators
5. STL Functions
6. STL Algorithm
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.