const_iterator是声明iterator指向的对象是常量,即iterator指向常对象,其迭代器本身可以变;
const iterator是声明iterator是常量,其指向的对象可以改变,但其迭代器本身不能变;
eg.
vector<int>::const_iterator iter1 = vec.begin(); *iter = 3; //Error ++iter; //Ok
const vector<int>::iterator iter2 = vec.begin(); *iter = 4; //Ok ++iter; //Error
|