Difference between Vector and Array

Apr 12, 2014 at 11:37pm
What is the difference between an array and a vector
Apr 12, 2014 at 11:44pm
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.)
Apr 13, 2014 at 12:10am
What is a vector anyways?
Apr 13, 2014 at 12:16am
Apr 13, 2014 at 12:22am
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 Apr 13, 2014 at 12:35am
Apr 13, 2014 at 12:32am
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.
Apr 13, 2014 at 12:35am
OK, so should I learn to use an vector?
Last edited on Apr 13, 2014 at 12:41am
Apr 13, 2014 at 2:12am
I would say yes.
Apr 13, 2014 at 3:57am
Vectors can be resized on the fly, and are much easier to use overall. Arrays, once declared, cannot be.
Apr 14, 2014 at 11:24pm
Can anything be like a word array?
Apr 14, 2014 at 11:55pm
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>).
Apr 15, 2014 at 12:10am
Thank you
Last edited on Apr 15, 2014 at 12:12am
Topic archived. No new replies allowed.