string::rbegin |
public member function |
reverse_iterator rbegin();
const_reverse_iterator rbegin() const; |
|
Return reverse iterator to reverse beginning
Returns a reverse iterator referring to the last character in the string, which is considered the reverse beginning.
rbegin refers to the character right before the one that would be referred to by member end.
Parameters
none
Return Value
A reverse iterator to the reverse beginning of the string (i.e., the last character).
The type of this iterator is either string::reverse_iterator member type or string::const_reverse_iterator member type, which are compiler specific iterator types suitable to perform a reverse iteration through the elements of a string object.
Example
// string::rbegin and string::rend
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("now step live...");
string::reverse_iterator rit;
for ( rit=str.rbegin() ; rit < str.rend(); rit++ )
cout << *rit;
return 0;
}
|
This code prints out the reversed content of a string character by character using a reverse iterator that iterates between rbegin and rend. Notice how even though the reverse iterator is increased, the iteration goes backwards through the string (this is a feature of reverse iterators).
The actual output is:
Basic template member declaration
( basic_string<charT,traits,Allocator> )
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
|
See also
string::rend | Return reverse iterator to reverse end (public member function) |
string::begin | Return iterator to beginning (public member function) |
string::end | Return iterator to end (public member function) |