The C++ standard libraries include several very useful standard container classes. Containers are just data structures which hold other things, and they are very useful. The structures are array, vector, deque (both array-like structures of variable size), list (which is doubly-linked), set, multiset, map and multipmap. The last four allow fast search based on a key, and they are generally implemented using a tree structure.
The 2011 standard added unordered_set, unordered_multiset, unordered_map and unordered_multimap. These are similar in behavior to the existing structures, but based on hashing rather than a tree.
The array container was also introduced in 2011, which does not mean C++ didn't have arrays before then. The array container is based on the original native array inherited from plain C, which is discussed later.
Associated with each container is an appropriate iterator class which allows a program to step through the contents of the container. An iterator retains a location in a container and is used to loop through the container. If you are familiar with the Interator interface in Java, the purpose is the same, but absolutely everything else about it is different.
It is also possible to use the list form of the for
or
The way you declare cont is much like the way you declare a function parameter. If you want to change the collection, use a reference. If you don't want to change the collection, but the items are large, declare a const reference.
Containers are a C++-only feature.