Please debug
// Debug 7-3
// static field holds total winnings for all horses in the stable
// total winnings are shown after each horse wins,
// and then in summary at the end
#include
#include
using namespace std;
class RaceHorse
{
public:
string name;
int age;
double winnings;
static double stableWinnings;
private:
void setRaceHorseData(string, int, double);
void showRaceHorse();
};
void RaceHorse::setRaceHorseData(string raceHorseName, int raceHorseAge, double raceHorseWinnings)
{
name = raceHorseName;
raceHorseAge = age;
winnings = raceHorseWinnings;
stableWinnings += winnings;
}
void raceHorse::showRaceHorse()
{
cout << "RaceHorse: " << name << " has won $" << winnings << endl;
cout << "Total stable winnings are $" << stableWinnings << endl;
}
int main()
{
const int NUM = 3;
RaceHorse stable[NUM];
int x;
stable[0].setRaceHorseData("Secretariat", 25, 32000);
cout << "So far...";
stable[0].showRaceHorse();
stable[1].setRaceHorseData("Old Bones", 30, 15000);
cout << "So far...";
stable[1].showRaceHorse();
stable[2].setRaceHorseData("Citation", 5, 3500);
cout << "So far...";
stable[NUM].showRaceHorse();
cout << endl << "In summary:" << endl;
for(x = 0; x = NUM; ++x)
stable[x].showRaceHorse();
return 0;
}