接上节内容,反向迭代器(aoto的价值显示的更明显)
int main()
{
string s1("hello world");
//string::reverse_iterator rit = s1.rbegin();
auto rit = s1.rbegin();
while (rit != s1.rend())
{
(*rit) += 3;
cout << *rit << " ";
++rit;
}
cout << endl;
cout << s1 << endl;
Func(s1);
return 0;
}
这里就凸显的范围for 不能倒着遍历,只能正着遍历
四种迭代器:iterator,const_iterator,reverse_iterator,const_reverse_iterator