title: MAP C++ using itr.first->second VS itr->second
body: <p>In <a href="http://www.cplusplus.com/reference/map/map/insert/" rel="nofollow noreferrer">http://www.cplusplus.com/reference/map/map/insert/</a>, I am confused with the reasoning of doing <code>ret.first-&gt;second</code> or <code>it-&gt;second</code> to access the 2nd value.  Why was it necessary to do <code>.first-&gt;second</code> if you can do it with just <code>-&gt;second</code>?</p>
  
  <pre class="lang-cpp prettyprint-override"><code>// map::insert (C++98)
  #include &lt;iostream&gt;
  #include &lt;map&gt;
  
  int main ()
  {
    std::map&lt;char,int&gt; mymap;
    std::pair&lt;std::map&lt;char,int&gt;::iterator,bool&gt; ret;
    ret = mymap.insert ( std::pair&lt;char,int&gt;('z',500) );
    if (ret.second==false) {
      std::cout &lt;&lt; "element 'z' already existed";
      std::cout &lt;&lt; " with a value of " &lt;&lt; ret.first-&gt;second &lt;&lt; '\n';
    }
  
    // showing contents:
    std::cout &lt;&lt; "mymap contains:\n";
    for (std::map&lt;char,int&gt;::iterator it=mymap.begin(); it!=mymap.end(); ++it)
      std::cout &lt;&lt; it-&gt;first &lt;&lt; " =&gt; " &lt;&lt; it-&gt;second &lt;&lt; '\n';
  
    return 0;
  }
  </code></pre>