请教迭代器如何工作?
#include <iostream>#include <string>
using namespace std;
int main()
{
string str;
str = "Good";
str += ' ';
str += "afternoon!";
string::iterator it;
it = str.begin();
while( it != str.end() ){
cout<<*it;
it++;
}
cout<<endl;
string::reverse_iterator rit;
rit = str.rbegin();
while( rit != str.rend() ){
cout<<*rit;
rit++;
}
cout<<endl;
return 0;
}
中的str函数都是什么意思,谢谢