title: map erase error
body: <p>i have wriitten program for diffrent operations on maps.</p>
  
  <p>and a sample code of my program is given below.</p>
  
  <p>while running this code i am getting an error like map erase out of range exception.</p>
  
  <p>please help me to solve this.</p>
  
  <pre><code>  int main( )
    {
      using namespace std;
      map &lt;int, int&gt; m1;
  
      map &lt;int, int&gt; :: iterator m1_Iter;
      map &lt;int, int&gt; :: const_iterator m1_cIter;
      typedef pair &lt;int, int&gt; Int_Pair;
  
      m1.insert ( Int_Pair ( 1, 10 ) );
      m1.insert ( Int_Pair ( 2, 20 ) );
      m1.insert ( Int_Pair ( 3, 30 ) );
  
      m1_cIter = m1.end( );
      m1_cIter--;
      cout &lt;&lt; "The value of the last element of m1 is:\n" 
        &lt;&lt; m1_cIter -&gt; second &lt;&lt; endl;
  
      m1_Iter = m1.end( );
      m1_Iter--;
      m1.erase ( m1_Iter );
  
              m1_cIter = m1.begin( );
      m1_cIter--;
      m1.erase ( m1_cIter );
  
      m1_cIter = m1.end( );
      m1_cIter--;
      cout &lt;&lt; "The value of the last element of m1 is now:\n"
        &lt;&lt; m1_cIter -&gt; second &lt;&lt; endl;
      getchar();
    }
  </code></pre>