title: Overloading the << operator to print out a std::list
body: <p>I've been having some problems trying to implement an overloaded &lt;&lt; operator function that can print out a std::list which is a member of one of my classes. The class looks like this:</p>
  
  <pre><code>class NURBScurve {
    vector&lt;double&gt; knotVector;
    int curveOrder;
    list&lt;Point&gt; points;
  public:
    /* some member functions */
    friend ostream&amp; operator&lt;&lt; (ostream&amp; out, const NURBScurve&amp; curve);
  };
  </code></pre>
  
  <p>The key member variable I am interested in is the list of "Points" - this is another class that I have created which stores coordinates of a point along with associated member functions. When I try and implement the overloaded &lt;&lt; operator function as:</p>
  
  <pre><code>ostream&amp; operator&lt;&lt;( ostream &amp;out, const NURBScurve &amp;curve)
  {
   out &lt;&lt; "Control points: " &lt;&lt; endl;
   list&lt;Point&gt;::iterator it;
   for (it = curve.points.begin(); it != curve.points.end(); it++)
      out &lt;&lt; *it; 
   out &lt;&lt; endl;
   return out;
  }
  </code></pre>
  
  <p>I start to get problems. Specifically, I get the following error:
  error: </p>
  
  <pre><code>no match for ‘operator=’ in ‘it = curve-&gt;NURBScurve::points. std::list&lt;_Tp, _Alloc&gt;::begin [with _Tp = Point, _Alloc = std::allocator&lt;Point&gt;]()’
  /usr/include/c++/4.2.1/bits/stl_list.h:113: note: candidates are: std::_List_iterator&lt;Point&gt;&amp; std::_List_iterator&lt;Point&gt;::operator=(const std::_List_iterator&lt;Point&gt;&amp;)
  </code></pre>
  
  <p>I'm a bit stumped here, but I believe it has something to do with the list iterator I am using. I'm also not too confident with the notation of curve.points.begin().</p>
  
  <p>If anyone can shed some light on the problem I would appreciate it. I'm at the point where I've been staring at the problem for too long!</p>