4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by NavidV
0

They are like arrays, but you can dynamically add items to them using push_back. They also have a function size() to get the length of the vector. I find them amazingly useful!

0

Hi venkitce,
Vectors are a more "robust" version of standard arrays used in C++.

Syntax:
vector <data-type> anyName(anySize, initial value);

vector methods:
.at(index) Where index is the index of the vector array
.size() The number of elements of the array
.front() The first element value
.back() The last element value
.pop_back() Removes the last element of the vector array
.push_back(any_value) Add a value to the last element
.empty() Indicates if the vector array is empty (boolean)
.clear() Clears the entire vector array

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.