Difference between Vector and Array

What is the difference between an array and a vector
The difference is that you should probably use std::vector unless you have a good reason not to.

(std::vector is basically a resizable array with a bunch of other functions to make your life easier.)
What is a vector anyways?
Similar to arrays? How do you use them? If I want to make a program that has 10 numbers, and it will delete numbers you type. What should I use?
Last edited on
Arrays can be dynamic or static. Depending on how you create it. There is also std::array<t , size> which is a pretty much a static array like t array [size]. You probably want to use a std::vector<t> you aren't very specific on what you are trying to do. If you are unsure at the bottom of the link I showed it has a flow chart on which to use.
OK, so should I learn to use an vector?
Last edited on
I would say yes.
Vectors can be resized on the fly, and are much easier to use overall. Arrays, once declared, cannot be.
Can anything be like a word array?
Yes, look at std::string - it is basically a vector specified for words. If you meant a word array as in an array of words, you could have a vector of strings (i.e. std::vector<std::string>).
Thank you
Last edited on
Topic archived. No new replies allowed.