title: Referencing max/min int in set for c++
body: <p>Say that I have the following example using a set in c++:</p>
  
  <pre><code>set &lt;int&gt; a;
  for (int i = 0; i &lt;10; i++){
  //Assume i is a random number
  a.insert(i);
  }
  </code></pre>
  
  <p>How can you find the maximum and minimum values for the set example shown above? Ideally I thought that the following would work but it gives the following error:</p>
  
  <pre><code>error: cannot convert 'std::_Rb_tree_const_iterator&lt;int&gt;' to 'int' in assignment
  </code></pre>
  
  <p>I'm using the following functions to try getting max/min:</p>
  
  <pre><code>min = a.begin();
  max = a.end();
  </code></pre>