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