What are containers in C++ and in Object Oriented Programming ? Which objects are available as containers ?
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.
