-
Book Overview & Buying
-
Table Of Contents
C++ STL Cookbook - Second Edition
By :
This recipe is an example of a full-featured contiguous/random-access iterator. This is the most complete type of iterator for a container. A random-access iterator includes all the features of the other types of container iterators, along with its random-access capabilities.
While I felt it was important to include a complete iterator in this chapter, with over 200 lines of code this example is somewhat larger than the other examples in this book. I'll cover the essential components of the code here.
You may download the full source code at https://github.com/PacktPublishing/CPP-STL-Cookbook-Second-Edition/blob/main/Chap04/container-iterator.cpp.
To start, we need a container for our iterator. We'll use a simple array for this, and we'll call our class, Container. The iterator class is nested within the Container class.
All of this is designed to be consistent with the STL container interfaces.
Change the font size
Change margin width
Change background colour