Question of typedef

I would like to create(just a practice) a simple container
below is my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
template<typename T, size_t N>
class myArray
{
  typedef T                 value_type;

  typedef value_type*       pointer;
  typedef const value_type* const_pointer;
  typedef value_type&       reference;
  typedef const value_type& const_reference;

  typedef ptrdiff_t         difference_type;
  typedef size_t            size_type;

  typedef pointer           iterator;
  typedef const pointer     const_iterator;

  typedef reverse_iterator<iterator> reverse_iterator;//this line can't work
};

error message
error: 'reverse_iterator' does not name a type

I copy that line from the book "generic programming and the stl"
In fact, I don't know what is that line mean?
typedef reverse_iterator<iterator> reverse_iterator;
How could it define a type like that?

last, what should I do if I want to define a reverse iterator for myself?

Thanks a lot
Last edited on
class reverse_iterator is defined in <iterator> ( inside the std namespace )
http://www.cplusplus.com/reference/std/iterator/reverse_iterator/
You can read the reference page to see what such class should do.
Wouldn't the user also need the typename keyword to typedef a dependent type?

For example:
typedef typename std::reverse_iterator<iterator> reverse_iterator;
Last edited on
class reverse_iterator is defined in <iterator> ( inside the std namespace )
http://www.cplusplus.com/reference/std/iterator/reverse_iterator/
You can read the reference page to see what such class should do.
Thanks a lot
Topic archived. No new replies allowed.