A vector should always be considered the default containerobject unless you have good reason to use a more specialisedcontainer (such as a map, set or list).A vector is essentially a variable-length array whichautomatically grows to accommodate new elements. If you require afixed-length array, consider using std::array rather thanstd::vector or built-in array (C-style array).As well as encapsulating the array and its current length, avector also encapsulates a reserve to allow moderate expansionwithout reallocating the array upon every insertion. When thereserve is depleted, reallocation may occur however the optimumgrowth rate upon reallocation is around 160% which gives areasonable balance between performance and memory consumption. Youmay set your own reserve if you can predict how many insertions youneed to cater for, but in many cases there is very little to begained by doing so.Like all other standard-library containers, a vector is also aresource handle. That is, when a vector falls from scope, theelements within it are destroyed automatically. However, when theelements are pointers, the objects they refer to are not destroyedbecause pointers are not objects and therefore do not havedestructors. The majority of vectors we use contain pointers,particularly when working with polymorphic objects (where we referto a common base of the objects rather than the objectsthemselves). However, if a vector of pointers falls from scopebefore we destroy the objects it referred to, we create a resourceleak.To overcome this, we can easily populate vectors with smartpointers which are themselves resource handles with their owndestructors. When the vector of smart pointers falls from scope,the smart pointers are destroyed automatically, which in turnautomatically destroys the objects they referred to -- unless thesmart pointer is a shared pointer in which case the object is onlydestroyed when the final reference falls from scope. Either way, weeliminate the risk of creating a resource leak at little to no cost(shared pointers incur some cost due to reference counting, butthat cost is negligible compared to alternative solutions).Being a resource handle, vectors implement the move semanticthus making it possible to pass and return vectors by valueefficiently and at minimal cost. Built-in arrays, on the otherhand, cannot be passed by value at all because arrays decay topointers (hence we cannot implicitly copy a built-in array); we canonly pass them by reference. However, because of the implicit decayto a pointer, passing a built-in array by reference is actuallyslightly less efficient than passing a vector by reference becausethe pointer alone does not tell us how many elements it refers to,so we also need to pass the array size. A vector carries allinformation with it, so passing the reference alone suffices.