Erklärung von 'int Unfälle[5] Schatten für einen parameter-Fehler

Ich bin neu in C++ und finde keine Möglichkeit, um dieses Fehler. Soweit ich weiß, ich bin nicht überladen Variablen zu erstellen, die einen Konflikt mit der Namensgebung(das war die nächste Sache zu einer Sache, die ich finden konnte online). Jede Hilfe wäre sehr geschätzt werden.

#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;
}
Wenn Sie tatsächlich Lesen Sie den gesamten Fehler, es wird sehr wahrscheinlich sagen, die line-und Variablen-Namen, geben Sie eine Fehlermeldung.
Was genau ist dein problem? und verwenden Sie nicht goto.
Was ist der Fehler???
goto ist nicht schlecht an sich, aber es gibt keinen Grund um es hier zu verwenden.
Es gibt nur sehr wenige triftige Gründe für die Verwendung von goto im C++ - Anwendung. Keiner von denen passt für jemanden, der neu in C++.

InformationsquelleAutor jklazzara | 2013-04-28

Schreibe einen Kommentar