Vectors are sequence containers representing arrays that can change in size. They use contiguous storage locations for their elements so can be accessed in the same way and as efficiently as arrays, but unlike arrays their size can change dynamically, with their storage being handled automatically by the container.
Create a vector
#include <iostream>
#include <vector>
vector<string> MyVector1;
MyVector1.push_back("Hello"); //push_back = Add a new item to the end
MyVector1.push_back("World");
int Index;
for (Index = 0; Index < MyVector1.size(); Index++)
std::cout << "Next vector element: " << MyVector1[Index] << std::endl;
Length of a vector
= MyVector1.size();
Delete item at index
MyVector1.erase(MyVector1.begin()+2); //Delete vector entry at index 2
Delete all items
MyVector1.clear();
Insert item at index
MyVector1.insert((MyVector1.begin() + 0), "Hello"); //UInsert new item at index 0
