c 2b 2b stl vector basic

Solutions on MaxInterview for c 2b 2b stl vector basic by the best coders in the world

showing results for - "c 2b 2b stl vector basic"
Cecil
02 Feb 2017
1
2#include <iostream>
3#include <vector>
4using namespace std;
5
6int main()
7{
8    vector<int> v;
9    vector<int> a(5,1);
10    vector<int> last(a);
11    cout<<"Print last"<<endl;
12    for(int i:last){
13        cout<<i<<" ";
14    }cout<<endl;
15    cout<<"capacity "<<v.capacity()<<endl;
16    v.push_back(1);
17    cout<<"capacity "<<v.capacity()<<endl;
18    v.push_back(2);
19    cout<<"capacity "<<v.capacity()<<endl;
20    v.push_back(3);
21    cout<<"capacity "<<v.capacity()<<endl;
22    cout<<"size "<<v.size()<<endl;
23    cout<<"Element at second index "<<v.at(2)<<endl;
24    cout<<"front "<<v.front()<<endl;
25    cout<<"back "<<v.back()<<endl;
26    
27   
28}
29
30