• Source
    1. #include<iostream>
    2. // (1) include vector library
    3. #include<vector>
    4. using namespace std;
    5.  
    6. int main(){
    7. // (2) define vector as integer
    8.  
    9. vector <int> array1;
    10.  
    11. //(3) vector_name.push_back(data) is used to push data
    12. array1.push_back(32);
    13. array1.push_back(12);
    14.  
    15. //(4) leatest element is accessed using vector_name.back()
    16. cout <<"Leatest pushed element is :" <<array1.back()<<endl<<endl;
    17.  
    18.  
    19. //(5) you can know array size using vector_name.size();
    20. cout <<"The size of array is : "<<array1.size()<<endl<<endl;
    21.  
    22. //(6) you can access element by it's position like array
    23. cout <<"Element at position '0' is :" <<array1[0]<<endl<<endl;
    24.  
    25.  
    26.  
    27.  
    28. }