On 15 Apr 2008 at 8:27, jacox wrote:
what's the difference between vectors and arrays in C?
I only knew array, as data structure, and not vector!
When must i use vector and when array?
In C++, a vector is an array with some additional functionality. One of
the main advantages is that vectors support bounds checking: if you use
the at() method, the access will be bounds-checked and throw an
exception if the element does not exist. (You can also avoid bounds
checking by using [], which is overloaded.)
A vector will also grow dynamically as needed when you add elements to
it: an array's size is fixed once and for all when you define it.