title: How to output the last element of a set in C++?
body: <p>When I insert 3 elements into a set and then call <code>*s.end()</code>, I get the correct output of 3, as follows:</p>
  
  <pre><code>set&lt;int&gt; s; 
  
  s.insert(1);
  s.insert(2);
  s.insert(3);
  cout &lt;&lt; *s.end();
  </code></pre>
  
  <p>I then erase 2 values and insert 11, as follows:</p>
  
  <pre><code>s.erase(3);
  s.erase(2);
  
  s.insert(11);
  
  cout &lt;&lt; *s.end();
  </code></pre>
  
  <p>The new expected output of <code>*s.end()</code> should be 11. But the output is showing 2. No clue from where this 2 is coming. Any ideas?</p>
  
  <p>Expected Output: 3 11<br>
  Actual Output: 3 2  </p>
  
  <p>It's not clear where 2 is coming from.</p>