宣布';国际事故[5]和#x27;隐藏参数错误 我是C++新手,找不到任何方法来解决这个错误。据我所知,我并没有重载任何变量来与命名产生冲突(这是我能在网上找到的最接近的原因)。任何帮助都将不胜感激 #include <iostream> #include <iomanip> #include <string> using namespace std; int getNumAccidents(string); int findLowest(int accidents[]); int main() { const int ARRAY_SIZE = 5; int input; int accidents[ARRAY_SIZE]; int counter = 0; string regions[ARRAY_SIZE] = {"North", "South", "East", "West", "Central"}; string name; string lowestRegion; int lowest = 1000000000; while (counter < ARRAY_SIZE) { name == regions[counter]; accidents[counter] = getNumAccidents(name); counter++; } findLowest(accidents); system("PAUSE"); return 0; } int getNumAccidents(string name) { int input; validate: cout<<"Enter the number of accidents that took place in the "<<name<<" region in the last year:"<<endl; cin>>input; if (input < 0) { system("CLS"); cout<<"Invalid input: the number of accidents can not be negative."; goto validate; } return input; } int findLowest(int accidents[]) { const int ARRAY_SIZE = 5; string lowestRegion; int accidents[ARRAY_SIZE]; string regions[ARRAY_SIZE] = {"North", "South", "East", "West", "Central"}; int lowest = 0; int counter = 0; while (counter < ARRAY_SIZE) { if (accidents[counter] < lowest) { lowest = accidents[counter]; lowestRegion = regions[counter]; } counter++; } cout<<"The "<<lowestRegion<<" region had the least accidents in the past year at " <<lowest<<" accidents."<<endl; } #包括 #包括 #包括 使用名称空间std; int getnumacidents(字符串); int findLowest(int意外[]); int main() { 常量int数组_SIZE=5; int输入; int意外[数组大小]; int计数器=0; 字符串区域[数组大小]={“北”、“南”、“东”、“西”、“中”}; 字符串名; 弦下区域; int最低=100000000; while(计数器代码的一些有效理由。没有一个适合C++的新的人。这不是一个错误。一个拒绝编译它的编译器不符合语言定义。代码的含义是很明确的,尽管它可能不是你想要的。谢谢,解决了这个问题。我会设置T。他是我能尽快接受的答案。+1表示“两次事故”。程序不应该有任何事故。:-) int findLowest(int accidents[]) // ^^ { const int ARRAY_SIZE = 5; string lowestRegion; int accidents[ARRAY_SIZE]; // ^^

宣布';国际事故[5]和#x27;隐藏参数错误 我是C++新手,找不到任何方法来解决这个错误。据我所知,我并没有重载任何变量来与命名产生冲突(这是我能在网上找到的最接近的原因)。任何帮助都将不胜感激 #include <iostream> #include <iomanip> #include <string> using namespace std; int getNumAccidents(string); int findLowest(int accidents[]); int main() { const int ARRAY_SIZE = 5; int input; int accidents[ARRAY_SIZE]; int counter = 0; string regions[ARRAY_SIZE] = {"North", "South", "East", "West", "Central"}; string name; string lowestRegion; int lowest = 1000000000; while (counter < ARRAY_SIZE) { name == regions[counter]; accidents[counter] = getNumAccidents(name); counter++; } findLowest(accidents); system("PAUSE"); return 0; } int getNumAccidents(string name) { int input; validate: cout<<"Enter the number of accidents that took place in the "<<name<<" region in the last year:"<<endl; cin>>input; if (input < 0) { system("CLS"); cout<<"Invalid input: the number of accidents can not be negative."; goto validate; } return input; } int findLowest(int accidents[]) { const int ARRAY_SIZE = 5; string lowestRegion; int accidents[ARRAY_SIZE]; string regions[ARRAY_SIZE] = {"North", "South", "East", "West", "Central"}; int lowest = 0; int counter = 0; while (counter < ARRAY_SIZE) { if (accidents[counter] < lowest) { lowest = accidents[counter]; lowestRegion = regions[counter]; } counter++; } cout<<"The "<<lowestRegion<<" region had the least accidents in the past year at " <<lowest<<" accidents."<<endl; } #包括 #包括 #包括 使用名称空间std; int getnumacidents(字符串); int findLowest(int意外[]); int main() { 常量int数组_SIZE=5; int输入; int意外[数组大小]; int计数器=0; 字符串区域[数组大小]={“北”、“南”、“东”、“西”、“中”}; 字符串名; 弦下区域; int最低=100000000; while(计数器代码的一些有效理由。没有一个适合C++的新的人。这不是一个错误。一个拒绝编译它的编译器不符合语言定义。代码的含义是很明确的,尽管它可能不是你想要的。谢谢,解决了这个问题。我会设置T。他是我能尽快接受的答案。+1表示“两次事故”。程序不应该有任何事故。:-) int findLowest(int accidents[]) // ^^ { const int ARRAY_SIZE = 5; string lowestRegion; int accidents[ARRAY_SIZE]; // ^^,c++,function,parameters,shadow,C++,Function,Parameters,Shadow,您的findLowest中有两次事故如果您实际读取了整个错误,它很可能会告诉您导致错误的行和变量名。您的问题到底是什么?不要使用gotogoto本身也不错,但没有理由在这里使用它。有很多问题在C++应用程序中使用 Goto < /C>代码的一些有效理由。没有一个适合C++的新的人。这不是一个错误。一个拒绝编译它的编译器不符合语言定义。代码的含义是很明确的,尽管它可能不是你想要的。谢谢,解决了这个问题。我会设置T。他是我能尽快接受的答案。+1表示“两次事故”。程序不应该有任何事故。:-)

您的
findLowest中有两次
事故

如果您实际读取了整个错误,它很可能会告诉您导致错误的行和变量名。您的问题到底是什么?不要使用
goto
goto本身也不错,但没有理由在这里使用它。有很多问题在C++应用程序中使用<代码> Goto < /C>代码的一些有效理由。没有一个适合C++的新的人。这不是一个错误。一个拒绝编译它的编译器不符合语言定义。代码的含义是很明确的,尽管它可能不是你想要的。谢谢,解决了这个问题。我会设置T。他是我能尽快接受的答案。+1表示“两次事故”。程序不应该有任何事故。:-)
        int findLowest(int accidents[])
    //                      ^^
        {
         const int ARRAY_SIZE = 5;
         string lowestRegion;
         int accidents[ARRAY_SIZE];
 //               ^^