One fast question about vectors!

Dec 23, 2014 at 2:10pm
Hello!

I'm making a little 2D game in C++ using the SDL framework, but it's one thing I've thought a lot about while I have worked with the development of the game... is it bad to use vectors too often, and should I rather use arrays than vectors?
Personally I almost always use vectors instead of arrays, since vectors increase automatically in size.

Thanks for answers :D
Dec 23, 2014 at 2:28pm
It depends on your needs and the use case. There is benefits to using std::array over std::vector but generally that is only when you don't need a dynamic size (You know that the number of elements will stay the same for the lifetime of the object).

Now will it make to much of a difference if you do use std::vector all the time? No, most likely it will have no impact on the performance of you application since I assume it is small in size. Though when you get to AAA size games it is definitely something to be taken into consideration because of performance aspects and memory aspects.
Dec 23, 2014 at 2:44pm
@Zereo

Thanks :D
Topic archived. No new replies allowed.