'{' 标记 C++ 之前的预期非限定 ID

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17314271/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 21:05:17  来源:igfitidea点击:

expected unqualified-id before '{' token c++

c++

提问by Tiro Sagacious

I'm facing titled problem in my assignment at line 60. Please anyone help me as quick as possible.

我在第 60 行的作业中遇到了标题问题。请任何人尽快帮助我。

59 void storeFile();
60 {
61 cout<< "All the data members are stored in file." << endl;
62 
63 ofstream outFile;
64 const char *outputFileName = ("record.txt");
65 outFile.open(outputFileName, ios::out);
66 
67 if(!outFile)
68 {
69      cout<< "\nUnable to open the file." << outputFileName << endl;
70      }
71 
72      else
73          {
74              outFile VUID; endl;
75              outFile campusID; endl;
76              outFile studentName; endl;
77              outFile fatherName; endl;
78                  }
79 };

error: expected unqualified-id before '{' token c++ at line 60

错误:第 60 行的“{”标记 c++ 之前的预期未限定 ID

回答by Didier Trosset

Remove the ;at the end of line 59.

删除第;59 行末尾的 。

By the way, as ChrisCM and U2CO3 have written, the ;at end of line 79 is not needed, even if that one does not generate a compilation error.

顺便说一下,正如 ChrisCM 和 U2CO3 所写的,;不需要第 79 行的末尾,即使那个不会产生编译错误。

回答by Alexandru Lache

It seems mistakenly it was added a ;at line 59

似乎错误地;在第 59 行添加了一个

void storeFile();

Replace it with

将其替换为

void storeFile()

回答by Alexandru Lache

And probably delete the one on line 79 too.

也可能删除第 79 行的那个。