title: c++ getline compile error when called from function
body: <p>// why does this work?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main() {
    ifstream inputStream("scores.txt");
    string line;
    getline(inputStream, line);
    cout &lt;&lt; line;
    return 0;
  }
  </code></pre>
  
  <p>// but this fails with compiler errors.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  ifstream GetStream() {
    ifstream inputStream("scores.txt");
    return inputStream;
  }
  
  int main() {
    ifstream inputStream = GetStream();
    string line;
    getline(inputStream, line);
    cout &lt;&lt; line;
    return 0;
  }
  </code></pre>
  
  <p>compile on mac osx 10.6 w/ g++ 4.2.1</p>
  
  <p>georges-iMac:cs106b george$ g++ help.cpp -o help
  /usr/include/c++/4.2.1/bits/ios_base.h: In copy constructor ‘std::basic_ios >::basic_ios(const std::basic_ios >&amp;)’:
  /usr/include/c++/4.2.1/bits/ios_base.h:779: error: ‘std::ios_base::ios_base(const std::ios_base&amp;)’ is private
  /usr/include/c++/4.2.1/iosfwd:55: error: within this context
  /usr/include/c++/4.2.1/iosfwd: In copy constructor ‘std::basic_ifstream >::basic_ifstream(const std::basic_ifstream >&amp;)’:
  /usr/include/c++/4.2.1/iosfwd:89: note: synthesized method ‘std::basic_ios >::basic_ios(const std::basic_ios >&amp;)’ first required here 
  /usr/include/c++/4.2.1/streambuf: In copy constructor ‘std::basic_filebuf >::basic_filebuf(const std::basic_filebuf >&amp;)’:
  /usr/include/c++/4.2.1/streambuf:794: error: ‘std::basic_streambuf&lt;_CharT, _Traits>::basic_streambuf(const std::basic_streambuf&lt;_CharT, _Traits>&amp;) [with _CharT = char, _Traits = std::char_traits]’ is private
  /usr/include/c++/4.2.1/iosfwd:86: error: within this context
  /usr/include/c++/4.2.1/iosfwd: In copy constructor ‘std::basic_ifstream >::basic_ifstream(const std::basic_ifstream >&amp;)’:
  /usr/include/c++/4.2.1/iosfwd:89: note: synthesized method ‘std::basic_filebuf >::basic_filebuf(const std::basic_filebuf >&amp;)’ first required here 
  help.cpp: In function ‘std::ifstream GetStream()’:
  help.cpp:9: note: synthesized method ‘std::basic_ifstream >::basic_ifstream(const std::basic_ifstream >&amp;)’ first required here </p>