C + + also has a very common container is the vector container, he is an array implementation, is a variable-length container, in many cases can simplify our programming.
Use vector to add header file
#include <vector>
Then using std::vector
or using namespace Std;
Initialization and definition of vectors
Since vector is a function template, so the system does not know what type of vector each element is, so we need to develop, define an int type vector container when,vector<int> A; you can define a vector container in which an element is an int.
There are several ways to initialize it:
Vector<int> A (b)//use another vector to initialize a vector.
Vector<int> A (3,1)//initialization vector is 3 x 1
vector<int> a{1,2,3};//initialization vector is
Adding elements to the vector container
To use the Push_back method built into the class, you can add an element to the last side of the class as if it were a stack.
The other operations are similar to the string container, +,+=, and comparing symbols.
Reprint Link: http://blog.csdn.net/sanwenyublog/article/details/18006769
Vector container for C + +