#include <iostream>
#include <string>
#include<fstream>
#include <algorithm>
#include <iterator>
#include <vector>
using
namespace
std;
int
_tmain(
int
argc, _TCHAR* argv[])
{
vector<
int
> myVec;
myVec.push_back(0);
myVec.push_back(1);
myVec.push_back(2);
copy( myVec.begin(),myVec.end(),ostream_iterator<
int
>( cout,
" "
));
cout<<endl;
const
vector<
int
>::iterator cite = myVec.begin();
*cite = 10;
//可行
//++cite; //错啦错误
copy( myVec.begin(),myVec.end(),ostream_iterator<
int
>( cout,
" "
));
cout<<endl;
vector<
int
>::const_iterator icte = myVec.begin();
// *icte = 100; //error C3892: “icte”: 不能给常量赋值
++icte;
//可行
copy( myVec.begin(),myVec.end(),ostream_iterator<
int
>( cout,
" "
));
cout<<endl;
return
0;
}
|
==============================================================================
本文转自被遗忘的博客园博客,原文链接:http://www.cnblogs.com/rollenholt/archive/2012/03/27/2420182.html,如需转载请自行联系原作者