class MyString
{
private:
char *m_string;
int m_size;
int m_reserved_size;
public:
typedef char * reverse_iterator;
typedef const char * const_reverse_iterator;
reverse_iterator rbegin();
{
return reverse_iterator(end());
}
const_reverse_iterator rbegin() const;
reverse_iterator rend();
{
return reverse_iterator(begin());
}
const_reverse_iterator rend() const;
int main()
{
MyString str("this is a test string");
MyString::reverse_iterator rit;
for (rit = str.rbegin(); rit != str.rend(); rit++)cout << *rit;
}
预期结果:“ gnirts tsi si siht”,但是我有一个错误。请帮助我做正确的事。我应该定义reverse_iterator
以及如何执行。