迭代器的类型共有4种:<T>::Iiterator,<T>::const_iterator,<T>::reverse_iterator,<T>::const_reverse_iterator
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
using namespace std;
int main()
{
string line = "you,are,robert";
//返回结果是常量反向迭代器,所以这里必须定义一个常量反向迭代器
string::const_reverse_iterator it = find(line.crbegin(),line.crend(),',');
cout << *it << endl;
//line.crbegin()必须在it的前面,这两个迭代器必须保持字面的先后顺序
//(rbegin就在最前面,rend最后)
string word(line.crbegin(),it);
//string new_word(word.rbegin(),word.rend());
//sort(word.begin(),word.end());
//sort(word.rbegin(),word.rend());
cout << "cout the word:" << endl;
cout << word << endl;
for(auto i = word.rbegin();i != word.rend();++i)
co