ellipsis wrote:
buddywithgol wrote:
Can anyone explain to me what is a vector in C++ in layman's term?
Don't paste a part of a article to me, because that'd be useless
A vector is a collection of a specific type of items. An array is a set collection.
Vectors and arrays are similar because they both store items (of the same type); however, they are different because vectors can have any size while arrays have a set maximum capacity.
Therefore, vectors are "dynamic" because they can expand and contract when necessary.
In non-layman's terms: vectors are wrapped arrays.
In my personal experience, vectors are more useful and practical than arrays. If an application requires many arrays with large capacities, initializing these arrays will choke the program. With vectors, you may have as many "arrays" as you need and you don't need to initialize each place holder. So these vectors will expand as the program runs and various items are stored and removed, and so forth.