title: C++ - Print Out Objects From Set
body: <p>If I have a C++ set and iterator:</p>
  
  <pre><code>set&lt;Person&gt; personList;
  set&lt;Person&gt;::const_iterator location;
  </code></pre>
  
  <p>How can I print out the contents of the set? They are all person objects, and I have overloaded operator&lt;&lt; for Person.</p>
  
  <p>The line that errors is in a basic for loop:</p>
  
  <pre><code>cout &lt;&lt; location
  </code></pre>
  
  <p>Netbeans gives:</p>
  
  <blockquote>
    <p>proj.cpp:78: error: no match for ‘operator&lt;&lt;’ in ‘std::cout &lt;&lt; location’</p>
  </blockquote>
  
  <p>It looks like it wants an overload for the iterator's operator&lt;&lt;.</p>
  
  <p>Basically, I am taking objects that used to be stored in an array format, but are now in a set. What is the equivalent to <code>cout &lt;&lt; array[i]</code> for sets?</p>