Can anyone tell me why this code is getting build errors, but Microsoft Visual won't highlight any problems?

[ Input "exams.dat" consist of...
abcdefabcdefabcdefab
1234567 abcdefabcdefabcdefab
9876543 abddefbbbdefcbcdefac
5554446 abcdefabcdefabcdef
4445556 abcdefabcdefabcdefabcd
3332221 abcdefghijklmnopqrst ...]

// This program reads a file with exam answers and an exam key, and prints the scores in a new file.
// ****************************************************************************************************************************

#include <fstream>
#include <string>

using namespace std;

void examine(string key, string test, ofstream outFile);
// This function takes the answer key, the exam information, and the output file variable
// and prints the student's ID number along with their score.

int main()
{
ifstream inFile; // Declares the input file variable
ofstream outFile; // Declares the output file variable
string key; // Declares the answer key string variable
string test; // Declares the string variable for each exam information

// Opens files
inFile.open("exams.dat");
outFile.open("scores.dat");

// Gets the first line from the file, which is the answer key
getline(inFile, key);

// Loop performs for each line of the file (or each exam)
while(inFile)
{
getline(inFile, test);

// examine function
examine(key, test, outFile);
}

// Closes files
inFile.close();
outFile.close();

return 0;
}



void examine(string key, string test, ofstream outFile)
// Pre: The answer key is provided as a string, the test information is provided as a string, and the output file has been opened.
// Post: The student ID and their score is written in the output file.
{
int length; // Declares the int variable for the length of the answers string
string idnumber; // Declares string variable for the student's ID number
string answers; // Declares string variable for the student's answers

// Breaks the test string into the student ID and answers strings
idnumber = test.substr(0, 7);
answers = test.substr(8, 30);

// Find the length of the answers string
length = answers.length();

if (length > 20) // If the length of the answers string is greater than 20, then print...
outFile << idnumber << " Too many answers" << endl;
else if (length < 20) // Else if the length of the answers string is less than 20, then print...
outFile << idnumber << " Too few answers" << endl;
else // Else...
{
int count = 0; // Assigns the int variable loop counter to 0
int score = 0; // Assigns the int variable for student score to 0
int invalid = 0; // Assigns the int variable invalid to 0, this tests the data input later
char indexKey; // Declares the char variable indexKey, the char taken from the answer key
char indexAnswer; // Declares the char variable indexAnswer, the char taken from the student's answers string

while (count < length) // While the iteration count is less than the length of the string
{
// Gets the char from the answer key
indexKey = key.at(count);

// Gets the char from the student's answers string
indexAnswer = answers.at(count);

if (indexKey == indexAnswer) // If both of the answers are the same...
score = score + 1; // ...add 1 to the students score
else if (indexAnswer != 'a' || indexAnswer != 'b' || indexAnswer != 'c' || indexAnswer != 'd' || indexAnswer != 'e' || indexAnswer != 'f')
invalid = invalid + 1; // Else if the answer is not a, b, c, d, e, or f, then add 1 to the invalid variable

// Increase the iteration counter by 1
count++;
}


if (invalid == 0) // If no answers were invalid, print...
outFile << idnumber << " " << score << endl;
else // Else print to the file that there were invalid answers
outFile << idnumber << " Invalid answers" << endl;
}
}
What are the errors?
It just says there are build errors no explanation. This is what it gives me in the output window:

1>------ Build started: Project: problem8-7, Configuration: Debug Win32 ------
1> problem8-7.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\fstream(1116): error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ios(176) : see declaration of 'std::basic_ios<_Elem,_Traits>::basic_ios'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> This diagnostic occurred in the compiler generated function 'std::basic_ofstream<_Elem,_Traits>::basic_ofstream(const std::basic_ofstream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Builds fine without any errors for me.

+1 Zhuge. Please post the errors you're getting and what lines they're on.
closed account (DSLq5Di1)
The outFile parameter in examine(), streams cannot be copied, pass by reference ofstream& outFile.
That's the thing! I don't see any errors! There aren't errors underlined anywhere! When I try to build it still says "There were build errors." I don't get it.
@sloppy9 I just tried that. Still getting build errors...
@sloppy9 Ignore my last post. It worked! Thank you very much. I'm finally getting an output. Now I just need to figure out why it is slightly wrong...
Doh, I copy/pasted the code into the wrong file and wasn't actually compiling it. Now I feel like a dufus.

Glad sloppy figured it out.
Topic archived. No new replies allowed.