title: Wrong type of iterator used
body: <p>I'm implementing a map as part of my HW assignment. The map should support two types of iterators:</p>
  
  <ul>
  <li>iterator - allows changing the map.</li>
  <li>constant_iterator - doesn't allow changing the map.</li>
  </ul>
  
  <p>I have the following methods:</p>
  
  <pre><code>Map::const_iterator begin() const;
  Map::const_iterator end() const;
  Map::iterator begin();
  Map::iterator end(); 
  </code></pre>
  
  <p>However when I test my implementation with the following code:</p>
  
  <pre><code>for(Map&lt;std::string,int&gt;::const_iterator it = msi.begin(); it != msi.end(); ++it) {
      std::cout &lt;&lt; *it &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>I get the following problem:</p>
  
  <pre><code>map_test.cpp:49:43: error: no viable conversion from 'Map&lt;basic_string&lt;char&gt;, int&gt;::iterator' to 'Map&lt;std::string, int&gt;::const_iterator'
          for(Map&lt;std::string,int&gt;::const_iterator it = msi.begin(); it != msi.end(); ++it) {
                                                   ^    ~~~~~~~~~~~
  ./map_new.h:57:3: note: candidate constructor not viable: no known conversion from 'Map&lt;basic_string&lt;char&gt;, int&gt;::iterator' to 'const
        Map&lt;basic_string&lt;char&gt;, int&gt;::const_iterator &amp;' for 1st argument
                  const_iterator(const Map&lt;KeyType, DataType&gt;::const_iterator&amp; sIterator): 
                  ^
  </code></pre>
  
  <p>Which means that the compiler selects the wrong begin/end methods.</p>
  
  <p>How can I solve this problem?</p>