title: Errors when passing ifstream file through a function
body: <p>Here is my code:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iomanip&gt;
  #include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include &lt;cstring&gt;
  #include &lt;cctype&gt;
  using namespace std;
  
  // include .h file that holds function ot write header
  #include "WriteE3RptHdr.h"
  
  // declare global constant
  const int NUM_QTS = 15;
  
  // declare struct to hold info on student and answers
  struct StudRpt {
      char answers[NUM_QTS];
      string firstName;
      string lastName;
      char answerKey[NUM_QTS];
      string testKey;
      string testData;
  };
  
  StudRpt Data;
  
  // function prototypes
  StudRpt StoreAnswerKey(StudRpt Data, ifstream inFile);
  StudRpt StoreStudData(StudRpt Data, ifstream inFile);
  void WriteRpt(StudRpt Data, ofstream&amp; outFile);
  
  int main()
  {
      int correct;
      int inforrect;
      int score;
      // delcare and open file streams
      ifstream inFile;
      ofstream outFile;
      inFile.open("in.data");
      outFile.open("out.data");
  
      // call function included from .h file
      WriteRptHdr(outFile);
  
      StoreAnswerKey(Data, inFile);
  
      // priming read
      StoreStudData(Data, inFile);
  
      while (inFile) {
          StoreStudData(Data, inFile);
          WriteRpt(Data, outFile);
      }
      inFile.close();
      outFile.close();
  }
  //----------------------------------------------------
  StudRpt StoreAnswerKey(StudRpt Data, ifstream inFile) {
      int i;
      for (i = 0; i &lt; NUM_QTS; i++) {
          inFile &gt;&gt; Data.answers[i];
      }
  
      return Data;
  }
  </code></pre>
  
  <p>The function WriteRptHdr is included from the .h file. it passes an ofstream through a function-- I've tested it, and it works just fine. But the ifstream inFile doesn't work (the program is meant to read in a answer key, and compare them to the answers a student gives. I can't get it to read in the answer key from the ifstream being passed)</p>
  
  <p>I'm using Pico. This is what I get as an error:</p>
  
  <pre><code>In function 'int main()':
  Tester.cxx:48: note: synthesized method '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;)' first required here
  Tester.cxx:48: error: initializing argument 2 of 'StudRpt StoreAnswerKey(StudRpt, std::ifstream)'
  </code></pre>