string::crbegin string::crend

const_reverse_iterator crbegin() const noexcept;
功能:crbegin是最后一个字符,crend第一个字符的前一个。迭代器向左移动是“+”,向右移动是“-”

#include <iostream>
#include <string>

using namespace std;

int main()
{
string s1("hello");
string::const_reverse_iterator it = s1.crbegin();
cout << *it << endl;//o
it = s1.crend() - 1;//h
cout << *it << endl;
return 0;
}

posted @ 2019-12-23 18:15  MoonXu  阅读(330)  评论(0编辑  收藏  举报