title: C++ map::erase() does not erase data
body: <p>I'm trying to test C++ <code>map::erase()</code> with the following code:</p>
  
  <pre><code>//file user.h
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;cstring&gt;
  
  using namespace std;
  
  class User {
      string name;
      int id;
  public:
      User(const string&amp; name, int id) : name(name), id(id) {}
      int getID() const {return id;}
      ~User(){}
  };
  
  //file main.cpp
  #include "user.h"
  using namespace std;
  
  typedef map&lt;string, User*&gt; Dict;
  
  int main()
  {
      Dict dict;
      dict["Smith"] = new User("Smith", 666); //Id = 666
      dict["Adams"] = new User("Adams", 314); //Id = 314
  
  
      auto it = dict.find("Adams"); //look for user 'Adams'
  
      if (it == dict.end())         
  
      //show 'not Found' if didn't find 'Adams'
      cout &lt;&lt; "not Found" &lt;&lt; endl; 
  
      else
      //else, show the Id = 314
      cout &lt;&lt; "id1: " &lt;&lt; it-&gt;second-&gt;getID() &lt;&lt; endl;
  
  
      //Here I think there is a problem
      //I ask to delete Adams from the list
      dict.erase(it);
      //So in this print the ID shouldn't be found
      cout &lt;&lt; "id2: " &lt;&lt; it-&gt;second-&gt;getID() &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>After I try to delete the item from the list it seems like it is not deleted as the program shows the following:</p>
  
  <pre><code>pc@pc:~/Test$ ./main
  id1: 314
  id2: 314
  </code></pre>
  
  <p>As I understand <code>id2</code> shouldn't show any value. Is this good or did I misunderstood the use of <code>erase</code>. If yes, how can I delete the item after it is shown?</p>