i tried to read/write an array to a file but gotten the "no matching operator" error. I've read through for possible causes for this error but my code doesnt commit any syntax error. Need some advice!
readData function
1 2 3 4 5 6 7 8 9 10 11
void Registration::readData()
{
inFile.open("rinput.txt");
inFile >> studentId >> semester >> count;
for(int i = 0; i < count; i++)
{
inFile >> courses[i]; //error in this line
}
inFile.close();
}
writeData function
1 2 3 4 5 6 7 8 9 10 11 12 13
void Registration::writeData()
{
outFile.open("routput.txt");
outFile << "Student ID: " << studentId << '\n'
<< "Semester: " << semester << '\n';
for(int i = 0; i < count; i++)
{
outFile << courses[i] << '\n'; //error in this line
}
outFile.close();
}
the array courses[i] is declare in a class called registration. I've also declared 'Course courses[MaxCourses];' in the .h file.
previously it was overloaded but i removed the friend operator to this ( as part of my tasks given).
I've read through many similar articles but is often the misuse of the '<<' and '>>' operator. Could the problem be somewhere else?