title: auto, error: map iterator has no member named ‘first`
body: <pre><code>map&lt;string, int&gt; M;
  for (auto E: M) 
  { 
      cout &lt;&lt; E.first &lt;&lt; ": " &lt;&lt; E.second &lt;&lt; endl; 
      F &lt;&lt; E.first &lt;&lt; ": " &lt;&lt; E.second &lt;&lt; endl; 
  }; 
  </code></pre>
  
  <p>I am learning c++ and I am confused with auto. I am trying to convert the above code into the following code( the above code with auto works correctly)</p>
  
  <pre><code>map&lt;string, int&gt; M;
  for (map&lt;string, int&gt; :: iterator p = begin(M); p != end(M); p ++ )
  {
      cout &lt;&lt; p.first &lt;&lt; ": " &lt;&lt; p.second &lt;&lt; endl;
      F &lt;&lt; p.first &lt;&lt; ": " &lt;&lt; p.second &lt;&lt; endl;
  }
  </code></pre>
  
  <p>I got the following error:</p>
  
  <pre><code> error: ‘std::map&lt;std::basic_string&lt;char&gt;, int&gt;::iterator’ has no member named ‘first’
       cout &lt;&lt; p.first &lt;&lt; ": " &lt;&lt; p.second &lt;&lt; endl;
   error: ‘std::map&lt;std::basic_string&lt;char&gt;, int&gt;::iterator’ has no member named ‘second’
       cout &lt;&lt; p.first &lt;&lt; ": " &lt;&lt; p.second &lt;&lt; endl;
   error: ‘std::map&lt;std::basic_string&lt;char&gt;, int&gt;::iterator’ has no member named ‘first’
       F &lt;&lt; p.first &lt;&lt; ": " &lt;&lt; p.second &lt;&lt; endl;
   error: ‘std::map&lt;std::basic_string&lt;char&gt;, int&gt;::iterator’ has no member named ‘second’
       F &lt;&lt; p.first &lt;&lt; ": " &lt;&lt; p.second &lt;&lt; endl;
  </code></pre>
  
  <p>Why it does not work?</p>