Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

C++ blocks


buddywithgol's Avatar
Member
0 0

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


Mb0742's Avatar
Ultimate Headshot
0 0

Laymen terms it is similar to an array in a scripting language. Why?

Because c* arrays cannot be appended to and a vector you can.


Arabian's Avatar
Member
0 0

In laymen's terms? Vector is a fancy term for dynamic array, which is a data structure similar to an array list, though with slightly different functionality, log time, and methods that make it better option in some situations, and should be considered a tertiary structure in the vein of linked lists and balanced trees.


ellipsis's Avatar
...
0 -1

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.


Arabian's Avatar
Member
0 0

ellipsis wrote: [quote]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.[/quote]

Practical only in some situations. Obviously the context calls for different structures, and dynamic arrays/vectors are heavier weight than your average array.

Keep this in mind and here's a good link with some O(n) comparisons and functionality explanations:

Here.