title: What is the difference between STL containers iterator and C pointer iterator
body: <p>i am writing a reverse iterator as a part of my own custom vector class. Up till now what i have written is as following.</p>
  
  <pre><code>class MyVector
  {
    public:
  
    typedef T                           value_type;
    typedef value_type*                 pointer;
    typedef const value_type*           const_pointer;
    typedef value_type&amp;                 reference;
    typedef const value_type&amp;           const_reference;
    typedef pointer                     iterator;
    typedef const_pointer               const_iterator;
    typedef size_t                      size_type;
  
      class reverse_iterator
      {
          private:
  
          iterator iter;
  
          public:
  
          inline reverse_iterator(iterator a=0) : iter(a) {}
          inline reverse_iterator(const reverse_iterator&amp; rev_iter) : iter(rev_iter.iter) {}
          inline reverse_iterator&amp; operator++()
          {
              --iter;
              return *this;
          }
          // and remaining other operator functions
      };
  
    inline iterator begin (void) { return ((iterator)data_array);           }
    inline iterator end (void)   { return ((iterator)data_array+number_of_elements); }
    inline reverse_iterator      rbegin(void)    { return end()-1;}
    inline reverse_iterator      rend(void)      { return begin()-1;}
  
  
      //functions for myvector class 
  }; //end of Myvector class
  </code></pre>
  
  <p>in above class iterater is just C style pointer and reverse_iterator is class. So when i do</p>
  
  <pre><code>    main()
      {
          myVector&lt;int&gt; i;
          myVector&lt;int&gt;::reverse_iterator rit= i.begin();
      }
  </code></pre>
  
  <p>my reverse_iterator is initialised with <strong>begin()</strong> function and code is compiling and running. But this does not happen in case of STL's iterator and reverse_iterator. They prevent such initialisation. e.g. reverse_iterator not allow himself to be initialised with <strong>begin()</strong> function, it must be initialised with <strong>rbegin()</strong>. </p>
  
  <p>So what should i do to avoid such kind of initialization ?. Should i write a different iterator like which is in STL. And i think it is not possible to write it.. Please give me some solution...</p>