1 #include<iostream>
2 #include<vector>
3 using namespace std;
4
5 void print( vector<int> &vec )
6 {
7 for ( vector<int>::iterator it = vec.begin(); it!=vec.end(); it++ )
8 cout<<*it<<' ';
9 cout<<endl;
}
void push( vector<int> &vec, int value )
{
vec.push_back(value);
}
int main()
{
vector<int> first;
vector<int> second (,); // four ints with value 100
print(second);
vector<int> third ( second.begin()+, second.end() );
print(third);
vector<int> fourth (third);
//construct from arrays
int arrays[] = {,,,,,};
vector<int> fifth ( arrays, arrays + sizeof(arrays)/sizeof(int) );
print(fifth);
push(fifth, );
print(fifth);
fifth.pop_back();
print(fifth);
fifth.pop_back();
print(fifth);
cout<<"capacity is "<<fifth.capacity()<<endl;
cout<<"size is "<<fifth.size()<<endl;
fifth.reserve();
cout<<"capacity is "<<fifth.capacity()<<endl;
cout<<"size is "<<fifth.size()<<endl;
print(fifth);
// erase the first 3 elements:
fifth.erase(fifth.begin(), fifth.begin()+);
for (int i=; i<fifth.size(); i++ )
cout<<fifth[i]<<' ';
cout<<endl;
return ;
}