undefined reference error in class

I'm trying to take the program slow aka building it slow so this is what I have so far. I receive an error :
undefined reference to Player Player (char const, int, int, int)
collect2:id returned1 exit status
every time I build. I've tried changing several things around. the error persists.

Appreciate a more experience eye to help

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
  class Player
{
public:
  Player();
  Player(const char[], int, int, int );
    
  void printPlayer();

  void setName(const char [] );
  void changeGoals( int );
  void changeAssists( int );
  void changeRating( int );

  int getGoals();
  int getAssists();
  int getRating();

private:
  char name[50];
  int goals;
  int assists;
  int rating;
};


//Function Prototypes


//**********************************************************************************


int main ()
{
Player player1( "Andrew Krutke", 1, 1, 1);  //error occurs here
//Player player2();

cout<<"First Player Object"<<endl;
player1.printPlayer();


return 0;
}



//Methods


/***************************************************************************
This Method will display player information and add up goals
and assists to equal points.
***************************************************************************/

void Player::printPlayer ()
	{
		int points;
		cout<< name << endl;
		points=goals+assists;
		cout <<"Goals:"<< goals << setw(3) << "Assist:" << assists << setw(3) << "Points:"<< points <<setw(3) << "Plus/Minus:" <<rating << endl;
	}

//*********************************
void Player::setName(const char newName[])
	{	
		strcpy (name, newName);
	
	}
//********************************

void Player::changeGoals(int goalsScored)
	{
	if (goalsScored <0)
	cout <<"error: goals cannots be negative" <<endl;
	else assists +=goalsScored;
	}
//***********************************************	 
void Player::changeAssists (int assistsEarned)
	{
	if (assistsEarned<0)
	cout << "error:goals cannot be negative:" << endl;
	else 
	assists+=assistsEarned;
	
	}
	
//***************************************************
void Player::changeRating(int plusMinusChange)
	{
	rating+=plusMinusChange;
	
	}
//**************************************************
int Player::getGoals()
	{
	return goals;
	}
//********************************
int Player::getAssists()
	{
	return assists;
	}
//**********************************
int Player::getRating()
	{
	return rating;
	}

Last edited on
Update to code, realized I missing constructors.
Now the issue lies in correctly building the code.
My values came back as garbage

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include <iostream>
#include <iomanip>
#include <string.h>
using namespace std;


//CLASS DECLARED
class Player
{
public:
  Player();
  Player(const char[], int, int, int );
    
  void printPlayer();

  void setName(const char [] );
  void changeGoals( int );
  void changeAssists( int );
  void changeRating( int );

  int getGoals();
  int getAssists();
  int getRating();

private:
  char name[50];
  int goals;
  int assists;
  int rating;
};




//Function Prototypes


//**********************************************************************************


int main ()
{
Player player1( "Andrew Krutke", 1, 1, 1);
//Player player2();

cout<<"First Player Object"<<endl;
player1.printPlayer();

return 0;
}



//Constructors

Player::Player()
{
	char name[] = "\0";
	goals = 0;
	assists = 0;
	rating = 0;
	
}



Player::Player (const char[], int g, int a, int r)
	{
		setName("none");
		changeGoals(g);
		changeAssists(a);
		changeRating(r);
	}




//Methods


/***************************************************************************
This Method will display player information and add up goals
and assists to equal points.
***************************************************************************/

void Player::printPlayer ()
	{
		int points;
		cout<< name << endl;
		points=goals+assists;
		cout <<"Goals:"<< goals << setw(3) << "Assist:" << assists << setw(3) << "Points:"<< points <<setw(3) << "Plus/Minus:" <<rating << endl;
	}

//*********************************
void Player::setName(const char newName[])
	{	
		strcpy (name, newName);
	
	}
//********************************

void Player::changeGoals(int goalsScored)
	{
	if (goalsScored <0)
	cout <<"error: goals cannots be negative" <<endl;
	else assists +=goalsScored;
	}
//***********************************************	 
void Player::changeAssists (int assistsEarned)
	{
	if (assistsEarned<0)
	cout << "error:goals cannot be negative:" << endl;
	else 
	assists+=assistsEarned;
	
	}
	
//***************************************************
void Player::changeRating(int plusMinusChange)
	{
	rating+=plusMinusChange;
	
	}
//**************************************************
int Player::getGoals()
	{
	return goals;
	}
//********************************
int Player::getAssists()
	{
	return assists;
	}
//**********************************
int Player::getRating()
	{
	return rating;
	}

Topic archived. No new replies allowed.