-11

我在作业中面临标题问题。请任何人尽快帮助我。

/*
    member function of studentInfo class; store the value of all data members in 
    the text file named "record.txt", on separate lines in the text file.
*/
void storeFile()
{
   cout<< "All the data members are stored in file." << endl;
   ofstream outFile;
   const char* outputFileName = "record.txt";
   outFile.open(outputFileName, ios::out);
   if(!outFile)
   {
       cout<< "\nUnable to open the file." << outputFileName << endl;
   }
   else
   {
       outFile vuID;
       outFile endl;
       outFile campusID;
       outFile endl;
       outFile studentName;
       outFile endl;
       outFile fatherName;
   }
}
4

3 回答 3

2
outFile endl;

这不好。endlstd命名空间中的标识符。你想用这个做什么?这没有意义。

于 2013-06-26T09:07:01.763 回答
1

您需要将变量放入 outputFile 例如

outFile << vuID;
于 2013-06-26T09:06:42.533 回答
1
outFile vuID

不是正确的形式,与

utFile endl;

它应该是

outFile << vuID

outFile << endl;
于 2013-06-26T09:06:46.910 回答