预备知识:
几种初始化vector对象的方式:
vector<T> v1; //vector保存类型为T的对象。默认构造函数v1为空
vector<T> v2(v1); //v2是v1的一个副本
vector<T> v3(n,i); //v3包含n个值为i的元素
vector<T> v4(n); //v4含有值初始化的元素的n个副本
程序清单:
输出结果:
longmenyu@longmenyu-Vostro-1088:~/test/code/cpp$ ./iterator_test
The first contents of the vectors is below:
9 9 9 9 9 9 9 9 9 9 0 1 2 3 4 5 6 7 8 9
The after contents of the vectors is below:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0