const_iterator,const 迭代器
const 迭代器:是迭代器产量,该迭代器的值不能被修改,且需要初始化,初始化之后不能指向其他元素。 const_iterator:当我们对const_iterator类型解引用时,返回一个const值,所以只能读,不能写。它是一种迭代器类型。 e.g: for ( vector<int>::const_iterator iter = ivec.begin(); iter != ivec.end(); ++iter) //good { cout << *iter << " "; //print each element in ivec } PS://此处必看!!!
vector<int>::const_iterator //an iterator that cannot write element, eg:cannot *iter=5,but can ++iter const vector<int>::iterator //an iterator whose value cannot change, eg:cannot ++iter
2013-03-29