title: Using getline in an implementation file while the istream is in the main
body: <p>I need to use the function getline to be able to read in the spaces within a string. Currently, I'm reading word by word and any space will input the next word into a different variable. A small extract of the code is as below.</p>
  
  <pre><code>istream &amp; operator &gt;&gt;( istream &amp; input, Unit &amp; C )
  {
      input &gt;&gt; C.unID &gt;&gt; C.unName &gt;&gt; C.credits &gt;&gt; C.Result &gt;&gt; C.mDay &gt;&gt; C.mMonth &gt;&gt; C.mYear; 
      return input;
  }
  
  
  ostream &amp; operator &lt;&lt;( ostream &amp; os, const Unit &amp; C )
  {
      os &lt;&lt; "  Unit ID:  " &lt;&lt; C.unID &lt;&lt; '\n';
  
      os &lt;&lt; "  Unit Name: " &lt;&lt; C.unName &lt;&lt; '\n'
        &lt;&lt; "  Credits: " &lt;&lt; C.credits &lt;&lt; '\n'
        &lt;&lt; "  Result: " &lt;&lt; C.Result &lt;&lt; " marks" &lt;&lt; '\n'
        &lt;&lt; "  Date: " &lt;&lt; C.mDay &lt;&lt; " " &lt;&lt; C.mMonth &lt;&lt; " " &lt;&lt; C.mYear &lt;&lt; '\n';
      return os;
  }
  </code></pre>
  
  <p>Note that I only need getline for unName.</p>
  
  <p>As for the infile, it's in my main.cpp. Code are as below.</p>
  
  <pre><code>ifstream infile( "rinput.txt" );
    if( !infile ) return -1;
  
    Student R;
    infile &gt;&gt; R;
  
  
    ofstream ofile( "routput.txt" );
  
    ofile &lt;&lt; R
      &lt;&lt; "Number of units = " &lt;&lt; R.GetCount() &lt;&lt; '\n'
      &lt;&lt; "Total credits     = " &lt;&lt; R.GetCredits() &lt;&lt; '\n';
  </code></pre>
  
  <p>The code works fine and all.</p>