今日课堂练习:vector构造函数
cpp
#include <iostream>
#include <vector>
using namespace std;
void printVector(vector<int> &v)
{
vector<int>::iterator iter;
for(iter=v.begin(); iter != v.end(); iter++)
{
cout << *iter << " ";
}
cout << endl;
}
int main()
{
vector<int> v;
v.push_back(10);
v.push_back(20);
v.push_back(30);
v.push_back(40);
v.push_back(50);
printVector(v);
vector<int> v2 = v;
printVector(v2);
vector<int> v3(v2.begin()+2, v2.end());
printVector(v3);
return 0;
}