Problem when compiling

Hey guys, so I have another assignment and I've got it all ready to go, but when I try to build it, I'm getting an unresolved external symbol error again. I'm not sure why, I've included and added all header and implementation files. What am I doing wrong?

this is the source code:
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
 #include <iostream>
#include <string>

using namespace std;

#include "person.h"

int main()
{
	string name;
	int age;

	Person person1;
	Person person2("Harry Meade", 24);

	cout << "Please enter your name: ";
	cin >> name;
	cout << "Please enter your age: ";
	cin >> age;

	person1.setName(name);
	person1.setAge(age);

	cout << "Name: " << person1.getName() << endl;
	cout << "Age: " << person1.getAge() << endl;
	cout << "My name is: " << person2.getName() << endl;
	cout << "My age is: " << person2.getAge() << endl;
	

	

}


this is the header file:
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

#include <iostream>
#include <string>

using namespace std;


/* A class that consists of a persons' name and age
*/
class Person{
public:
	/* constructs a Person object with parameters
	 parameter personName = name
	 parameter personAge = age
	 */
	Person(string personName, int personAge);

	/* constructs a Person object with default
	parameters
	*/
	Person();

	/* sets the name of the person
	parameter newName = new person name
	*/
	void setName(string newName);

	/* sets the age of the person
	parameter newAge = new person age
	*/
	void setAge(int newAge);

	/* gets the name of the person
	and returns it
	*/
	string getName();

	/* get the age of the person
	and returns it
	*/
	int getAge();



private:
	string name;
	int age;

};


and this is the implementation file:
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
#include <iostream>
#include <string>

using namespace std;

#include "person.h"

Person::Person(string personName, int personAge)
{
	name = personName;
	age = personAge;
}

void Person::setName(string newName)
{
	name = newName;
}

void Person::setAge(int newAge)
{
	age = newAge;
}

string Person::getName()
{
	return name;
}

int Person::getAge()
{
	return age;
}


Any help is really appreciated. Thanks.
The problem is that, in your header file, your class claims to have a Person constructor which takes no arguments. Your compiler is like "Okay cool", but it never finds an implementation for that constructor (it doesn't find it because it doesn't exist - you didn't write it).
Thanks so much! I added
Person::Person()
{
age = 0;
}
to my implementations, and that did it.

I appreciate the help! Thanks again.
Topic archived. No new replies allowed.