首页 > 其他 > 详细

实践出真知(一)

时间:2015-07-23 17:26:29      阅读:223      评论:0      收藏:0      [点我收藏+]
 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  
技术分享

 

实践出真知(一)

原文:http://www.cnblogs.com/jieforever/p/4670806.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!