title: attempting to reference a deleted function
body: <p>I'm trying to learn about the fstream class and I'm having some trouble. I created a couple of txt files, one with a joke and the other with a punchline (joke.txt) and (punchline.txt) just for the sake of reading in and displaying content. I ask the user for the file name and if found it should open it up, clear the flags then read the content in. but I cant even test what it reads in because I'm currently getting errors regarding a deleted function but I don't know what that means</p>
  
  <p>error 1:</p>
  
  <pre><code>"IntelliSense: function "std::basic_ifstream&lt;_Elem, _Traits&gt;::basic_ifstream(const std::basic_ifstream&lt;_Elem, _Traits&gt;::_Myt &amp;) [with _Elem=char, _Traits=std::char_traits&lt;char&gt;]" (declared at line 818 of "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\fstream") cannot be referenced -- it is a deleted function
  </code></pre>
  
  <p>the second error is the exact same but for the 2nd function (displayLastLine())</p>
  
  <p>and error 3:</p>
  
  <pre><code>Error   1   error C2280: 'std::basic_ifstream&lt;char,std::char_traits&lt;char&gt;&gt;::basic_ifstream(const std::basic_ifstream&lt;char,std::char_traits&lt;char&gt;&gt; &amp;)' : attempting to reference a deleted function
  </code></pre>
  
  <p>and here's my code:</p>
  
  <pre><code>#include "stdafx.h" 
  #include &lt;string&gt;    
  #include &lt;iostream&gt;  
  #include &lt;fstream&gt;   
  
  using namespace std; 
  
  void displayAllLines(ifstream joke);
  void displayLastLine(ifstream punchline);
  
   int main()          
  {
      string fileName1, fileName2;
      ifstream jokeFile, punchlineFile;
  
  
      // Desribe the assigned project to the User
      cout &lt;&lt; "This program will print a joke and its punch line.\n\n";
  
      cout &lt;&lt; "Enter the name of the joke file (ex. joke.txt): ";
      cin  &gt;&gt; fileName1;
      jokeFile.open(fileName1.data());  
      if (!jokeFile)
      {
          cout &lt;&lt; "  The file " &lt;&lt; fileName1 &lt;&lt; " could not be opened." &lt;&lt; endl;
      }
  
      else
      {   
          cout &lt;&lt; "Enter name of punch line file (ex. punchline.txt): ";
          cin  &gt;&gt; fileName2;
          punchlineFile.open(fileName2.data());  
          if (!punchlineFile)
          {
              cout &lt;&lt; "  The file " &lt;&lt; fileName2 &lt;&lt; " could not be opened." &lt;&lt; endl;
              jokeFile.close();
          }
  
          else
          {   
              cout &lt;&lt; endl &lt;&lt; endl; 
  
              displayAllLines(jokeFile);
  
              displayLastLine(punchlineFile); 
              cout &lt;&lt; endl;
  
              jokeFile.close();
              punchlineFile.close();
          }
      }
  
  
      // This prevents the Console Window from closing during debug mode
      cin.ignore(cin.rdbuf()-&gt;in_avail());
      cout &lt;&lt; "\nPress only the 'Enter' key to exit program: ";
      cin.get();
  
      return 0;
  }
   void displayAllLines(ifstream joke)
   {
       joke.clear();
       joke.seekg(0L, ios::beg);
       string jokeString;
       getline(joke, jokeString);
       while (!joke.fail())
       {
           cout &lt;&lt; jokeString &lt;&lt; endl;
       }
   }
   void displayLastLine(ifstream punchline)
   {
       punchline.clear();
       punchline.seekg(0L, ios::end);
       string punchString;
       getline(punchline, punchString);
       while (!punchline.fail())
       {
           cout &lt;&lt; punchString &lt;&lt; endl;
       }
   }
  </code></pre>