Help!!

i get
Error 1 error C4700: uninitialized local variable 'goals' used


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  #include <iostream>
#include <iomanip>
#include <string>
#include "PR.h"
using namespace std;
int main()
{
	int n;                //number of footballers
	int i;                //loop for user selection
	int goals;            //number of goals scored by player
	int choice;           //choices between divisionOne and divisionTwo
	string name;          //name of football player
	string club;          //club for football player
	PR *footballStar[50]; // limit only to 50 player and stores into the division chosen either division<1> or division<2>
	cout << "Insert number of footballer<s>:\t";
	cin >> n;
	cout << endl;
	for (i = 0; i < n; i++) //number of footballer user entered
	{
		cin.get();
		cout << "Name of footballer " << i + 1 << ":";  //i+1 is when the number of the footballer is added
		getline(cin, name);
		cout << endl;
		cout << "Name of club " << i+1 << ":";
		getline(cin, club);
		cout << endl;
		cout << "Division One<1> or Division Two<2>?: ";
		cin >> choice;
		//while loop execution
		while (i = 1) //choices are one
		{
			if (choice == 1) //if user select division <1>
			{
				footballStar[i] = new PR(name, club, goals, choice); //[i] refers to loop for the user selection: Division<1> where footballStar points to the PR *footballStar[50]
				break;
			}
			else if (choice == 2) //if user select division <2>
			{
				footballStar[i] = new PR(name, club, goals, choice); //[i] refers to loop for the user selection: Division<2> where footballStar points to the PR *footballStar[50]
				break;
			}
			else
			{
				cout << "Footballer division entered in does not exist in the system.";
				cout << "\nPlease key in again.";
				cout << endl << endl;
				i--; //error message and value of counter i will be decreased 
				break;
			}
		}
		cout << "Number of goals scored in this season: " << goals << endl;
	}
	for (i = 0; i < n; i++)
	{
		footballStar[i]->getbonussalary();
	}
	return(0);
}

Please because i need to submit it by today. Anyone help me....
Line 34, 39: What do you think the value of goals is when you pass it to the PR constructor?

You don't show PR's constructor, so have to assume you're passing this as an input value.
AbstractionAnon


correction has been made. Thank you my friend.
Topic archived. No new replies allowed.