Unresolved External Symbol

I get these errors when attempting to compile my code:
1>Student.obj : error LNK2019: unresolved external symbol "public: void __thiscall Student::getSsn(long)" (?getSsn@Student@@QAEXJ@Z) referenced in function _main
1>Student.obj : error LNK2019: unresolved external symbol "public: void __thiscall Student::getName(char * const)" (?getName@Student@@QAEXQAD@Z) referenced in function _main
1>c:\documents and settings\ematheson\my documents\visual studio 2010\Projects\Student\Debug\Student.exe : fatal error LNK1120: 2 unresolved externals

I'm really new at C++ especially classes. I have no idea what is going wrong.

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

#include <iostream>
#include <string.h>
using namespace std;

class Student {
private:
	long int studentSsn;
	char studentName[80];
public:
	Student ();
	void getName (char[]);
	void setName (char[]);
	void getSsn (long int);
	void setSsn (long int);
};

Student::Student() {
	studentSsn=99999999;
	char* studentName="undefined";
}

void Student::setName (char* tempName) { // Sets the studentName var to the assigned value
	strcpy(studentName, tempName);
}

void Student::setSsn (long int tempSSN) { // Sets the studentSsn to the assigned value
	if(tempSSN > 0) {
		studentSsn = tempSSN;
	} else {
		studentSsn = 999999999;
	}
}

void main() {
	Student student1;
	Student student2;
	char sName1[80];
	char sName2[80];
	long int social1 = 0;
	long int social2 = 0;

	// Set values for Student 2
	student2.setName("John Doe");
	student2.setSsn(123456789);

	// Should return default values for student1 into these variables
	student1.getName(sName1);
	student1.getSsn(social1);

	// Should return our values for student2 into these variables
	student2.getName(sName2);
	student2.getSsn(social2);

	// Output!
	cout << "Name for student 1 is " << sName1 << " and ssn is " << social1 << endl;
	cout << "Name for student 2 is " << sName2 << " and ssn is " << social2 << endl;
}
You've only declared those functions; you haven't provided an implementation for them.
Topic archived. No new replies allowed.