Different ways to copy a vector in C++

An array has a fixed size when it is declared. But if we want a dynamic array whose size can vary at runtime then we use vector. Elements are inserted in vector from end using push_back(). Like arrays, elements in vector are also stored contiguously and they can traversed using iterators. Iterators return pointers to elements.


This is a companion discussion topic for the original entry at http://iq.opengenus.org/copying-a-vector-in-cpp/