Vectors

How exactly do vectors work because I don't really see them that different from arrays. I was originally searching for the arraylist of java equivalent in c++. What I found was vectors and all the websites say that it is a dynamic array meaning that it changes size to fit what is required. In arraylist you could add arrays without designating a size and I thought that vectors could do the same, but in the examples in each one the code did eventually give the vector a size later on. Then I tried on my own making a vector with an unknown size and then trying to add elements to it, but that came up with an error.

So I'm a bit confused is vector like arraylist in that it has an automatically changing size to fit elements? Or does it just mean that you can change the size of the vector even after giving it a size in the beginning?
Last edited on
See http://www.cplusplus.com/reference/stl/vector/. To add elements to the array use push_back().
Thank you very much. Although now I feel like an idiot for not noticing that lol
Topic archived. No new replies allowed.