Could anyone explain me about vectors used in c++?

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!

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.