您的位置:首页 > 其它

const_interator的用法

2014-10-12 15:34 204 查看
// string::cbegin/cend
#include <iostream>
#include <string>

int main ()
{
  std::string str ("Lorem ipsum");
  for (auto it=str.cbegin(); it!=str.cend(); ++it)
    std::cout << *it;
  std::cout << '\n';

  return 0;
}


A const_iterator is an iterator that points to const content. This iterator can be increased and decreased (unless it is itself also const), just like the iterator returned
by string::begin, but
it cannot be used to modify the contents it points to, even if the string object
is not itself const.

注意的是:const_iterator不能改变所指向的值。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: