title: Function cannot be referenced as it is a deleted function
body: <p>Hello I am learning C++ from a book and am on a exercise question below</p>
  
  <p>Write a function that takes and returns an istream&amp;. The function should read the stream until it hits end-of-file. The function should print what it reads to the standard output. Reset the stream so that it is valid before returning the stream.</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;istream&gt;
  #include &lt;string&gt;
  #include &lt;string.h&gt;
  #include &lt;list&gt;
  #include &lt;vector&gt;
  #include &lt;fstream&gt;
  
  std::istream ReadFile(std::istream &amp;iStream)
  {
      std::string word;
      while (iStream &gt;&gt; word)
      {}
      std::cout &lt;&lt; "I read value " &lt;&lt; word &lt;&lt; std::endl;
      iStream.setstate(std::ios::goodbit);
      return iStream;
  
  }
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      ReadFile(std::cin);
  
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>The above is my attempt, however I am getting errors at the "return iStream" line.</p>
  
  <pre><code>Error1 error C2280: 'std::basic_istream&lt;char,std::char_traits&lt;char&gt;&gt;::basic_istream(const std::basic_istream&lt;char,std::char_traits&lt;char&gt;&gt; &amp;)' : attempting to reference a deleted function  
  
  2 IntelliSense: function "std::basic_istream&lt;_Elem, _Traits&gt;::basic_istream(const std::basic_istream&lt;_Elem, _Traits&gt;::_Myt &amp;) [with _Elem=char, _Traits=std::char_traits&lt;char&gt;]" (declared at line 77 of "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\istream") cannot be referenced -- it is a deleted function
  </code></pre>
  
  <p>I don't really know what these errors are, I am aware you can delete stuff but I am not onto that topic in the book yet. As far as I know I have not at all touched the istream file... Can someone help me please?</p>
  
  <p>Thanks!</p>