Thread: Array or Vector
View Single Post
  #2 (permalink)  
Old 11-16-2007, 05:30 PM
ShoeNinja's Avatar
ShoeNinja ShoeNinja is offline
Senior Member
 
Join Date: Oct 2007
Posts: 124
Rep Power: 0
ShoeNinja is on a distinguished road
Send a message via AIM to ShoeNinja
Default
If you know how many items you need to store, I think an array is the way to go. The advantage of a vector is its ability to change size. Basically if a vector is full and you add another object, the memory for that object is dynamically allocated. This does not happen in an array. To increase the size of an array, you have to create a new one and copy all of the original values.

So, in my opinion, if there is no chance that you will need more than 10 Strings, go with the array.
Reply With Quote