title: Making a read function that allows spaces in the input (C++)
body: <p>"Write a class named <code>Person</code> that represents the name and address of a person. Use a <code>string</code> to hold each of these elements. Add operations to read and print <code>Person</code> objects to the code you wrote."</p>
  
  <p>Note I haven't reached the section on access control yet. </p>
  
  <pre><code>#include &lt;iostream&gt; 
  #include &lt;string&gt;
  
  using std::string;
  
  struct Person
      {
          string name_var, address_var;
      };
  
  std::ostream &amp;print(std::ostream&amp;, const Person &amp;);
  std::istream &amp;read(std::istream&amp;, Person &amp;);
  
  
  std::istream &amp;read(std::istream &amp;is, Person &amp;item)
      {
           is &gt;&gt; item.name_var &gt;&gt; item.address_var;
           return is;
      }
  
  std::ostream &amp;print(std::ostream &amp;os, Person &amp;item)
      {
           os &lt;&lt; item.name_var &lt;&lt; " " &lt;&lt; item.address_var;
           return os;
      }  
  </code></pre>
  
  <p>With this I can only read single worded names and addresses if I use <code>std::cin</code> as the first argument to <code>read</code>, which isn't very useful. Can you somehow use <code>getline</code>? </p>