Pure Virtual Error, Please Help!

I am trying to get both PersonType class and EmployeeType class to be abstract and the pure virtual method is to be overiddin in the derived classes.

Here is my 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdlib>
#include <ctime>

using namespace std;

    class PersonType
    {
    private:
        string mFirstName;
	string mLastName;
	string mID;
    
    public:
	PersonType::PersonType(string firstName, string lastName, string id)
        {
            mFirstName = firstName;
	    mLastName = lastName;
	    mID = id;
	}

	virtual void PersonType::Display()
        {
			cout << "\n  Name: " << mFirstName << ", " << mLastName 
            << "\n  ID: " << mID;
        }
		virtual char PersonType::GetType(void) = 0;
    };

    class StudentType : public PersonType
    {
    private:
       
        string mProgram;

    public:
		
		char StudentType::GetType() {return 'S';}
		
		StudentType::StudentType(string firstName, string lastName, string id, string program)
            : PersonType(firstName, lastName, id)
        {
            mProgram = program; 
        }
		void StudentType::Display()
        {
			PersonType::Display();
			cout << "Program: " << mProgram;
        }
    };

    class EmployeeType : public PersonType
    {
    private:
        string mDept;
	string mDateOfHire;

    public:
        
		virtual char EmployeeType::GetType(); 

		EmployeeType::EmployeeType(string firstName, string lastName, string id, 
			string dept, string dateOfHire)
            : PersonType(firstName, lastName, id)
        {
            mDept = dept;
			mDateOfHire = dateOfHire;
        }
        
		void EmployeeType::Display()
        {
			PersonType::Display();
            cout << "\n  Dept: " << mDept; 
            cout << "\n  Date Of Hire: " << mDateOfHire;
        }
    };

    class StaffType : public EmployeeType
    {
    private:
        int mHoursWorked;
	double mPayRate;

    public:
        
	char StaffType::GetType(void) {return 'F';}
		
	StaffType::StaffType(string firstName, string lastName, string id, string dept, string dateOfHire, int hoursWorked, double payRate)
            : EmployeeType(firstName, lastName, id, dept, dateOfHire)
        {
            mHoursWorked = hoursWorked;
	    mPayRate = payRate;
        }

		void StaffType::Display()
        {
			EmployeeType::Display();
            cout << "\n  Pay: " << mPayRate * mHoursWorked; 
            
        }
    };

	class ProfessorType : public EmployeeType
	{
	private:
		
		double mSalary;

	public:
        
		char ProfessorType::GetType(void) {return 'P';}
		
		ProfessorType::ProfessorType(string firstName, string lastName, string id, string dept, 
			string dateOfHire, double salary)
			: EmployeeType(firstName, lastName, id, dept, dateOfHire)
		{
			mSalary = salary;
		}

		void ProfessorType::Display()
		{
			EmployeeType::Display();
			cout << "\n  Salary: " << mSalary; 
		}
    };

char DisplayMenu();
void AddNewPerson(string &firstName, string &lastName, string &id);
void AddNewEmployee(string &firstName, string &lastName, string &id, 
    string &dept, string &dateOfHire);
void AddNewProfessor(PersonType *personPtrAr[100], int &numPeople);
void AddNewStaff(PersonType *personPtrAr[100], int &numPeople);
void AddNewStudent(PersonType *personPtrAr[100], int &numPeople);
void DisplayEveryone(PersonType *personPtrAr[100], int numPeople);
void DisplayEmployees(PersonType *personPtrAr[100], int numPeople);
void DisplayProfessors(PersonType *personPtrAr[100], int numPeople);
void DisplayStaff(PersonType *personPtrAr[100], int numPeople);
void DisplayStudents(PersonType *personPtrAr[100], int numPeople);

void main()
{
    	
	int numPeople = 0;
    char option = ' ';
	PersonType *personPtrAr[100];
	
	cout << fixed << showpoint << setprecision(2);
    
	option = DisplayMenu();
	
	while(option != 'Q' || 'q')
    {
		switch(option)
        {
        case '1':
			AddNewStudent(personPtrAr, numPeople);
            break;
        case '2':
			AddNewStaff(personPtrAr, numPeople);
            break;
        case '3':
			AddNewProfessor(personPtrAr, numPeople);
            break;
        case '4':
            DisplayEveryone(personPtrAr, numPeople);
            break;
        case '5':
            DisplayStudents(personPtrAr, numPeople);
            break;
        case '6':
            DisplayEmployees(personPtrAr, numPeople);
			break;
        case '7':
            DisplayStaff(personPtrAr, numPeople);
            break;
		case '8':
            DisplayProfessors(personPtrAr, numPeople);
            break;
		default:
			cout << "\n\nInvalid Choice!\n\n";
			break;
        }
    }
}

char DisplayMenu()
{
	char choice = '0';

	cout << "\nDeVry University Menu\n";
    cout << "1 - Add New Student\n";
    cout << "2 - Add New Staff\n";
    cout << "3 - Add New Professor\n";
    cout << "4 - Display Everyone\n";
    cout << "5 - Display Student\n";
    cout << "6 - Display Employees\n";
	cout << "7 - Display Staff\n";
    cout << "8 - Display Professors\n";
	cout << "Q - Quit\n";	
    cout << "Enter choice: ";
	cin >> choice;
	return choice;

}
void AddNewPerson(string &firstName, string &lastName, string &id)
{
	cout << "Enter first name: ";
	cin >> firstName;
	cout << "Enter last name: "; 
	cin >> lastName;
	cout <<	"Enter ID Number: ";
	cin >> id;
}
void AddNewEmployee(string &firstName, string &lastName, string &id, 
    string &dept, string &dateOfHire)
{	
	AddNewPerson(firstName, lastName, id);
	cout << "Enter Employee's Dept: ";
	cin >> dept;
	cout << "Enter Employee's Date of Hire: ";
	cin >> dateOfHire;
}
void AddNewProfessor(PersonType *personPtrAr[], int &numPeople)
{
	string firstName = " ";
	string lastName = " ";
	string id = " ";
	string dept = " ";
	string dateOfHire = " ";
	double salary = 0.00;
	
	AddNewEmployee(firstName, lastName, id, dept, dateOfHire);
	
	cout << "Enter Professor's Salary: ";
	cin >> salary;
	
	personPtrAr[numPeople++] = new ProfessorType(firstName, lastName, id, dept, dateOfHire, salary);
}

void AddNewStaff(PersonType *personPtrAr[], int &numPeople)
{
	string firstName = " ";
	string lastName = " ";
	string id = " ";
	string dept = " ";
	string dateOfHire = " ";
	int hoursWorked = 0;
	double payRate = 0.00;

	AddNewEmployee(firstName, lastName, id, dept, dateOfHire);
	
	cout << "Enter Staff's Hours Worked: ";
	cin >> hoursWorked;
	cout << "Enter Staff's Pay Rate: ";
	cin >> payRate;
	
	personPtrAr[numPeople++] = new StaffType(firstName, lastName, id, dept, dateOfHire, hoursWorked, payRate);
	
}
void AddNewStudent(PersonType *personPtrAr[], int &numPeople)
{
	string firstName = " ";
	string lastName = " ";
	string id = " ";
	string program = " ";
	
	AddNewPerson(firstName, lastName, id);
	
	cout << "Enter Student's Program: ";
	cin >> program;
	
	personPtrAr[numPeople++] = new StudentType(firstName, lastName, id, program);
}
	

void DisplayEveryone(PersonType *personPtrAr[], int numPeople)
{
	for(int i = 0; i < numPeople; i++)
		personPtrAr[i]->Display();

}
void DisplayEmployees(PersonType *personPtrAr[], int numPeople)
{
	char type = ' ';
	
	for(int i = 0; i < numPeople; i++)
	{
		type = personPtrAr[i]->GetType();
		if(type == 'P' || 'F')
			personPtrAr[i]->Display();
	}
}
void DisplayProfessors(PersonType *personPtrAr[], int numPeople)
{
	char type = ' ';
	
	for(int i = 0; i < numPeople; i++)
	{
		type = personPtrAr[i]->GetType();
		if(type == 'P')
			personPtrAr[i]->Display();
	}
}
void DisplayStaff(PersonType *personPtrAr[], int numPeople)
{	
	char type = ' ';
	
	for(int i = 0; i < numPeople; i++)
	{
		type = personPtrAr[i]->GetType();
		if(type == 'F')
			personPtrAr[i]->Display();
	}
}
void DisplayStudents(PersonType *personPtrAr[], int numPeople)
{
	char type = ' ';
	
	for(int i = 0; i < numPeople; i++)
	{
		type = personPtrAr[i]->GetType();
		if(type == 'S')
			personPtrAr[i]->Display();
	}
}


This is the ERROR I keep getting any Help would be great, thanks.

StudentProfessorStaff.obj : error LNK2001: unresolved external symbol "public: virtual char __thiscall EmployeeType::GetType(void)" (?GetType@EmployeeType@@UAEDXZ)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Week 5 i Lab\Debug\Week 5 i Lab.exe : fatal error LNK1120: 1 unresolved externals
closed account (DSLq5Di1)
You haven't defined EmployeeType::GetType().
Remove bolded part:

1
2
//virtual char PersonType::GetType(void) = 0;
virtual char GetType(void) = 0;


Also you forgot to define EmployeeType's GetType method.
Topic archived. No new replies allowed.