好吧,我知道這是更多的文字比你想,但我真的無法找到下面的代碼期望「{」錯誤?除了預期未指明的ID錯誤?
#include <iostream>
using namespace std ;
int main(void)
{
int score1, score2;
PrintInfo() ;
score1 = GetScore(); // Call function GetScore, to obtain a value for score1.
if (RangeError()) ; // IF score1 is out of range, print an error message.
{
cout << "Sorry you entered an invalid score." << endl ;
}
else // THIS IS LINE 46, THIS IS THE ELSE IT IS TALKING ABOUT
{
score2 = Getscore ; // Call GetScore a second time, to obtain a value for score2.
if (RangeError()); // IF score2 is out of range, print an error message.
{
cout << "Sorry you entered an invalid score." << endl ;
}
else // ELSE, using a call to function maximum within a cout
{ // statement, print the maximum score.
cout << maximum() << endl ;
}
}
return 0;
}
問題那裏面有很多的,我知道,但主要問題似乎是周圍還有我的第二個。無論出於何種原因,我不斷收到以下錯誤:
lab05a.cpp:46:錯誤:「前 '其他'
lab05a.cpp預計`}:在全球範圍內:
lab05a.cpp: 46:錯誤:在'else'之前預期不合格id-
我知道這與包圍有關,但是我找不到任何問題!另外:我很抱歉缺少行號,我們沒有使用允許它們的編輯器。我可以添加它們,但爲了簡潔起見,我刪除了大量不相關的文本,添加它們不會爲錯誤提供適當的行號。因此,我將顯示第46行。由於問題似乎並不在其中,因此我刪除了大部分聲明。請幫助我,這是我第一次遇到一個我自己無法解決的問題。
你如果以後你有一個分號。另外,你似乎沒有調用'GetScore()'。 – chris