What are containers in C++ and in Object Oriented Programming ? Which objects are available as containers ?
![]() Don't want to miss a single bit? Subscribe By Email for Daily Jobs |
A container is an object that can store other objects as its elements. However all the objects stored in a container should be of the same data type. E.g. array is a container as it allows you to store multiple objects. However there are a few problems with arrays like an array can’t allow you to store an element anywhere in the middle of the array, an array cannot grow dynamically to append new elements at the end of the array.
A sequence container is the one which allows storing elements of the same type in a linear fashion. There are three objects which are sequence containers:
1. Vector: an array like container that allows storing elements of the same type and provides random access to these elements. Insertions and deletions at the end of the vector are efficient.
2. List: provides efficient insertions and deletions at any position within a list.
3. dequeue: double ended queue with constant time insertions and deletions both at the end and the beginning of the queue.
Related Articles
- What are Iterators in C++ and Object Oriented Programming ? Explain where we use them
- What are the differences between ArrayList and LinkedList types in Java ?
- What are Vectors in C++(Object Oriented Programming) and how are they used ?
- What are the difference between Set and List.in Java ?
- What are Templates in C++ ? How are Templates declared and used ?


