title: Issues overloading arrow ( -> ) operator c++
body: <p>I have a custom container to store data and an iterator to access it. The problem is the -> operator in the iterator is not allowing me to modify the data in the container.</p>
  
  <p>value_type is an std::pair&lt;></p>
  
  <p>data holder:</p>
  
  <pre><code>template &lt;class tree&gt;
  struct avl_node {
  private:
      typedef typename tree::key_type         Key;
      typedef typename tree::mapped_type      Type;
      typedef typename tree::value_type       value_type;
  public:
      typedef avl_node*                       node_ptr;
      typedef const avl_node*                 const_node_ptr;
      node_ptr _parentNode, _leftNode, _rightNode;
      int _balance;
      Key first;
      Type second;
  }
  </code></pre>
  
  <p>iterator:</p>
  
  <pre><code>template &lt;class tree&gt;
  class avl_iterator {
  public:
      typedef typename tree::node             node;
      typedef typename tree::node_ptr         node_ptr;
      typedef typename tree::const_node_ptr   const_node_ptr;
      typedef typename tree::utilities        utilities;
      typedef typename tree::value_type       value_type;
  private:
      node_ptr _node;
  public:
      avl_iterator() : _node()  { }
      avl_iterator( const node_ptr node ) : _node ( node ) { }
      ~avl_iterator() { _node = NULL; }
  
      avl_iterator&amp; operator=(const avl_iterator&amp; rhs) {
          _node = rhs._node;
          return (*this);
      }
      bool operator == ( const avl_iterator&amp; rhs ) { return ( _node == rhs._node); }
      bool operator != ( const avl_iterator&amp; rhs ) { return ( _node != rhs._node); }
  
      avl_iterator&amp; operator++()
      {
          _node = utilities::next_node( _node );
          return (*this);
      }
      avl_iterator&amp; operator ++( int ) {
          avl_iterator temp(*this);
          ++(*this);
          return(temp);
      }
  
      avl_iterator&amp; operator -- () {
          _node = utilities::prev_node( _node );
          return (*this);
      }
  
      avl_iterator&amp; operator -- ( int ) {
          avl_iterator temp(*this);
          --(*this);
          return(temp);
      }
  
      value_type&amp; operator * () {
          return value_type( node-&gt;first, node-&gt;second );
      }
  
      node_ptr operator -&gt; () const {
          return _node;
      }
  };
  </code></pre>
  
  <p>main</p>
  
  <pre><code>    try{
      using namespace avl;
      avltree&lt;int,int&gt; tree;
      tree.insert(intPair(1,1));
      tree.insert(intPair(2,1));
      tree.insert(intPair(3,1));
      tree.insert(intPair(4,1));
      tree.insert(intPair(5,1));
      tree.insert(intPair(6,1));
      tree.insert(intPair(7,1));
      tree.insert(intPair(8,1));
      tree.insert(intPair(9,1));
      tree.insert(intPair(10,1));
      tree.insert(intPair(11,1));
      tree.insert(intPair(12,1));
  
      avltree&lt;int,int&gt;::iterator it;
      //std::map&lt;int,int&gt;::iterator it;
      for( it = tree.begin(); it != tree.end(); ++it )
      {
          std::cout&lt;&lt; it-&gt;first &lt;&lt; " : ";
      }
      std::cout &lt;&lt; std::endl;
      for( it = tree.end(); it != tree.begin(); --it )
      {
          std::cout&lt;&lt; it-&gt;first &lt;&lt; " : ";
      }
      std::cout &lt;&lt; std::endl;
  
              it-&gt;first = 5;//shouldnt compile with this line of code, but does
              it-&gt;second = 10;
  }
  catch(...)
  {
      std::cout&lt;&lt;"Catch Block\n";
  }
  </code></pre>