DIR Return Create A Forum - Home
---------------------------------------------------------
ifaq
HTML https://ifaq.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: C/C++ related questions
*****************************************************
#Post#: 29--------------------------------------------------
Array vs Vector
By: avinash.srin Date: September 14, 2011, 6:30 am
---------------------------------------------------------
In C++, arrays are contiguous pieces of memory. They are
somewhat like blocks aligned together, each block is then given
a number, and to look at the contents of each block one only has
to supply the number of the block. All the elements of an array
must be of the same type.
A vector is similar to an array but with extended functionality.
One of the features of a vector is that if you use the at()
function, an exception will be thrown if you try and access an
element that doesn't exist. A vector is a template class, it is
a generic array of whatever type you want it to be. This gives
vectors a great deal of flexibility, they can be used as an
array of anything, you can even have a vector of vectors.
Vectors also have a number of useful functions (inbuilt API's)
which can tell you certain properties of the vector.
*****************************************************