From the course: C++ Templates and the STL
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Output iterators - C++ Tutorial
From the course: C++ Templates and the STL
Output iterators
- [Instructor] An output iterator is the compliment of the input iterator. It may be used to write a value once and then increment. Here I have a working copy of output-iterator.cpp from chapter three of the exercise files. The output iterator like the input iterator is defined in the iterator header separately from iostream even though it's normally used with iostream and just like the input iterator, the ostream iterator, the output iterator is defined separately from cout, because of the unique nature of cout and cin. So the output iterator is constructed here with a separator and so that space will be used to separate the output values. And here we simply list some integer values and we increment the output iterator and assign the values to the de-referenced output iterator and send endl and when I build and run, you see three simple. It prints the three values on the console. And the delimiter is inserted after every value. So the iterator is used just like a pointer, but only…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.