title: how to cout a vector of structs (that's a class member, using extraction operator)
body: <p>i'm trying to simply cout the elements of a vector using an overloaded extraction operator. the vector contians Point, which is just a struct containing two doubles.
  the vector is a private member of a class called Polygon, so heres my Point.h</p>
  
  <pre><code>#ifndef POINT_H
  #define POINT_H
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  struct Point
  {
    double x;
    double y;
    //constructor
    Point()
    {
     x = 0.0;
     y = 0.0;
    }
  
  friend std::istream&amp; operator &gt;&gt;(std::istream&amp; stream, Point &amp;p)
      {
      stream &gt;&gt; std::ws;
      stream &gt;&gt; p.x;
      stream &gt;&gt; p.y;
      return stream;
      }
  friend std::ostream&amp; operator &lt;&lt; (std::ostream&amp; stream, Point &amp;p)
  {
  stream &lt;&lt; p.x &lt;&lt;  p.y;
  return stream;
  }    
  };
  #endif
  </code></pre>
  
  <p>my Polygon.h</p>
  
  <pre><code>#ifndef POLYGON_H
  #define POLYGON_H
  #include "Segment.h"
  #include &lt;vector&gt;
  class Polygon
  {
      //insertion operator needs work
   friend std::istream &amp; operator &gt;&gt; (std::istream &amp;inStream, Polygon &amp;vertStr);
   // extraction operator
   friend std::ostream &amp; operator &lt;&lt; (std::ostream &amp;outStream, const Polygon &amp;vertStr);
  
     public:
     //Constructor
      Polygon(const std::vector&lt;Point&gt; &amp;theVerts);
      //Default Constructor
      Polygon();
      //Copy Constructor
      Polygon(const Polygon &amp;polyCopy);
        //Accessor/Modifier methods
      inline std::vector&lt;Point&gt; getVector() const {return vertices;}
      //Return number of Vector elements
      inline int sizeOfVect() const {return vertices.size();}
      //add Point elements to vector
      inline void setVertices(const Point &amp;theVerts){vertices.push_back (theVerts);}
  
   private:
  std::vector&lt;Point&gt; vertices;
  };
  </code></pre>
  
  <p>and Polygon.cc</p>
  
  <pre><code>using namespace std;
   #include "Polygon.h"
  // Constructor
  Polygon::Polygon(const vector&lt;Point&gt; &amp;theVerts)
      {
          vertices = theVerts;
      }
   //Default Constructor
  Polygon::Polygon(){}
  
  istream &amp; operator &gt;&gt; (istream &amp;inStream, Polygon::Polygon &amp;vertStr)
   {
      inStream &gt;&gt; ws;
      inStream &gt;&gt; vertStr;
      return inStream;
   }
  
  // extraction operator
   ostream &amp; operator &lt;&lt; (ostream &amp;outStream, const Polygon::Polygon &amp;vertStr)
  {
      outStream &lt;&lt; vertStr.vertices &lt;&lt; endl;
      return outStream;
   }
  </code></pre>
  
  <p>i figure my Point insertion/extraction is right, i can insert and cout using it</p>
  
  <p>and i figure i should be able to just......</p>
  
  <pre><code>cout &lt;&lt; myPoly[i] &lt;&lt; endl;  
  </code></pre>
  
  <p>in my driver? (in a loop) or even...</p>
  
  <pre><code>cout &lt;&lt; myPoly[0] &lt;&lt; endl; 
  </code></pre>
  
  <p>without a loop?
  i've tried all sorts of </p>
  
  <pre><code>myPoly.at[i];
  myPoly.vertices[i];
  </code></pre>
  
  <p>etc etc</p>
  
  <p>also tried all veriations in my extraction function</p>
  
  <pre><code>outStream &lt;&lt; vertStr.vertices[i] &lt;&lt; endl;
  </code></pre>
  
  <p>within loops, etc etc.</p>
  
  <p>when i just create a... </p>
  
  <pre><code>vector&lt;Point&gt; myVect;
  </code></pre>
  
  <p>in my driver i can just...</p>
  
  <pre><code>cout &lt;&lt; myVect.at(i) &lt;&lt; endl;
  </code></pre>
  
  <p>no problems.</p>
  
  <p>tried to find an answer for days, really lost and not through lack of trying!</p>
  
  <p>please excuse my lack of comments and formatting
  also there's bits and pieces missing.</p>