1 #include <cstdlib>
2 #include <iostream>
3 #include <vector>
4
5 using namespace std;
6 typedef int T;
7 // typedef vector<T> CT;
8 //template<typename T>
9
10
11
12 int main(){
13 vector<int> vv;
14 vv.reserve(20);
15 for(int i=0;i<20;i++)
16 vv.push_back(i);
17 vv[2]=14;//用地址+【】进行索引
18 vector<int>::iterator first=vv.begin();
19 //!!!定义向量的指针用该语句,而非用取地址符号来定义
20 cout<<vv[0]<<endl;
21
22 cout<<first[3]<<endl;
23 first=first+1;
24 cout<<first[3]<<endl; //地址加1后索引结果后移
25 system("PAUSE");
26 return 1;
27 }
28
29