title: istream overloading -reading string from file
body: <p>I am trying to read a list of Person objects from a file, outputs those objects to an in-memory stream. I am able to get it working if I dont have to read from a file, I can manaully enter each object value and its working fine, but I am struggling to pipe the extracted line from file as input to istream >> overloading operator</p>
  
  <p>Reads from a file</p>
  
  <pre><code>string str
  while (getline(inFile, str))
     {
       cout &lt;&lt; "line" &lt;&lt; str &lt;&lt; endl; // I am getting each line
       cin &gt;&gt; people // if I manually enter each parameter of object it works fine
       str &gt;&gt; people // ?? - doesnt work - how do i pipe??
     }
  
  Person.cpp
  // operator overloading for in operator
  istream&amp; operator&gt;&gt; (istream &amp;in, People &amp;y)
  {
  
      in &gt;&gt; y.firstName;
      in &gt;&gt; y.lastName;
      in &gt;&gt; y.ageYears;
      in &gt;&gt; y.heightInches;
      in &gt;&gt; y.weightPounds;
      return in;
  }
  
  class People
  {
    string firstName;
    string lastName;
    int ageYears;
    double heightInches;
    double weightPounds;
  
     // stream operator
    friend ostream&amp; operator&lt;&lt; (ostream &amp;out, People&amp;);
    friend istream&amp; operator&gt;&gt; (istream &amp;in, People&amp;);
  };
  </code></pre>