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不能改变所指向的值。
相关文章推荐
- C++中的const成员函数(函数声明后加const,或称常量成员函数)用法详解
- C++中 const的用法
- C++中const的用法
- const的用法及使用的优点
- C语言中const的用法
- const用法详解
- corecpp基础语法总结——const的用法
- 【C++】const 常引用的用法
- 标准C++中const关键字的用法总结
- const的用法及其重要性
- C++中const用法总结
- C#中const 和 readonly 修饰符的用法详解
- const 用法
- const关键字的用法
- const的用法说明
- c,c++中const的用法
- const_cast 用法
- C++ const用法及注意事项
- Z03 C++中const的通常用法
- const几种用法