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;
}

猜你喜欢

转载自www.cnblogs.com/xpylovely/p/12085233.html
今日推荐