Need help, I don't understand the error

This is the error i get:
1>------ Build started: Project: Employee and ProductionWorker Classes, Configuration: Debug Win32 ------
1> worker.cpp
1>worker.obj : error LNK2019: unresolved external symbol "public: __thiscall productionWorker::productionWorker(int,double)" (??0productionWorker@@QAE@HN@Z) referenced in function _main
1>worker.obj : error LNK2019: unresolved external symbol "public: __thiscall employee::employee(char,int,int)" (??0employee@@QAE@DHH@Z) referenced in function _main
1>E:\2. NOT COOL STUFF\SKOOL\2013\1. SPRING 2013\INTERMEDIATE C++\Employee and ProductionWorker Classes\Debug\Employee and ProductionWorker Classes.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


and here is my employee class:
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
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include <string>						// Needed for the string.
#include <iostream>
using namespace std;

class employee
{
private:
	char emplName;
	int emplNumber;
	int hireDate;

public:
	employee(char name, int n, int d);			// Constructor

	// "Set" and "Get" the Employee Name function.
	void setEmplName();
	char getEmplName() const;

	// "Set" and "Get" the Employee Number function.
	void setEmplNumber();
	int getEmplNumber() const;

	// "Set" and "Get" the Hire Date function.
	void setHireDate();
	int getHireDate() const;


void setEmplName(char name)
{
	emplName = name;
}

char getEmplName()
{
	return emplName;
}

void setEmplNumber(int n)
{
	emplNumber = n;
}

int getEmplNumber()
{
	return emplNumber;
}

void setHireDate(int d)
{
	hireDate = d;
}

int getHireDate()
{
	return hireDate;
}

}; 
#endif 


here is the production worker class
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
 #ifndef PRODUCTIONWORKER_H
#define PRODUCTIONWORKER_H
#include "employee.h"					// Needed for the employee class.
#include <iostream>
using namespace std;

class productionWorker : public employee
{
private:
	int shift;
	double hourlyPayRate;

public:
	productionWorker(int s, double hpr);

	// "Set" and "Get" the Shift function.
	void setShift();
	int getShift() const;

	// "Set" and "Get" the Hourly Pay Rate function.
	void setHourlyPayRate();
	double getHourlyPayRate() const;

void setShift(int s)
{
	shift = s;
}

int getShift()
{
	return shift;
}

void setHourlyPayRate(double hpr)
{
	hourlyPayRate = hpr;
}

double getHourlyPayRate()
{
	return hourlyPayRate;
}

};
#endif 


and here is the Worker main:
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
 #include "employee.h"
#include "productionWorker.h"
#include <cstring>
#include <string>
#include <iomanip>
#include <iostream>
using namespace std;

int main ()
{
	char response;
	const int SIZE = 100;	// Array size.
	char name[SIZE];
	int number, date, shift;
	double payRate;

	do
	{
		// Ask the user for the employee's name.
		cout << "What is the employee's name?" << endl;
		cin.getline(name, SIZE);
	
		// Ask the user for the employee's number.
		cout << "\nWhat is the employee's number?" << endl;
		cin >> number;
	
		cout << "\nWhat is the employee's hire date?\n";
		cout << "(Please enter the month, day, and year \n";
		cout << " without any slashes, dashes, commas, or other punctuation.)\n";
		cout << "For example, January 14, 1983 would look like 01141983. " << endl;
		cin >> date;
	
		cout << "\nWhat shift does the employee work? Shift 1, or Shift 2?" << endl;
		cin >> shift;
		if(shift < 0 || shift > 2)
		{
			cout << "An error occurred, please enter only 1 or 2 as a shift number." << endl;
			cin >> shift;
		}
	
		cout << "\nHow much does the employee make per hour? " << endl;
		cin >> payRate;
		
		// Create the Employee class object.
		employee into(name[100], number, date);

		// Create the Production Worker class object.
		productionWorker in(shift, payRate);

		

		// Display the employee data.
		cout << "\n\n----------Here is the employee's data:----------\n\n";
		cout << "	Employee's Name:			" << into.getEmplName() << endl;
		cout << "	Employee's Number:			" << into.getEmplNumber() << endl;
		cout << "	Employee's Hire Date:		" << in.getHireDate() << endl;
		cout << "	Employee's Shift:			" << in.getShift() << endl;
		
		cout << setprecision(2) << fixed;			// Set the decimal point for the Pay Rate.
		cout << "	Employee's Hourly Pay Rate: $" << in.getHourlyPayRate() << endl << endl;


		// Ask the user if they would like to rerun the program.
		cout << endl << "\nWould you like to run the program again?" << endl;
		cin >> response;
		cout << endl;

		// Allows the getline function to be used more than once in a do-while loop.
		cin.ignore();
	} while (response == 'y' || response == 'Y');

	return 0;
}
any and all help is appreciated, the problem has to with this:
1
2
3
4
5
                // Create the Employee class object.
		employee into(name[100], number, date);

		// Create the Production Worker class object.
		productionWorker in(shift, payRate);


but i'm not sure how to fix it.
You haven't defined either of your constructors.
i'm sorry, i'm not entirely sure what are the constructors...
would it be this area?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
private:
	int shift;
	double hourlyPayRate;

public:
	productionWorker(int s, double hpr);

	// "Set" and "Get" the Shift function.
	void setShift();
	int getShift() const;

	// "Set" and "Get" the Hourly Pay Rate function.
	void setHourlyPayRate();
	double getHourlyPayRate() const;
In employee.h it's the one with the comment that says: // constructor

In the snippet you just posted above the constructor is declared on line 6.
Last edited on
okay so i was able to fix what was wrong with it before.
But now, it doesn't run correctly. The part where it asks for the employee's name has a problem. Also, there seems to be a problem with where it displays an employee's data....
I really have no idea what i did that was so wrong.

here's the first header/class
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
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include <string>						// Needed for the string.
#include <iostream>
using namespace std;

class employee
{
private:
	string emplName;
	int emplNumber;
	int hireDate;

public:
	employee(string name, int n, int d)				// Constructor
	{
		emplName = name;
		emplNumber = n;
		hireDate = d;
	}

	// "Set" and "Get" the Employee Name function.
	void setEmplName();
	string getEmplName() const;

	// "Set" and "Get" the Employee Number function.
	void setEmplNumber();
	int getEmplNumber() const;

	// "Set" and "Get" the Hire Date function.
	void setHireDate();
	int getHireDate() const;


void setEmplName(string name)
{
	emplName = name;
}

string getEmplName()
{
	return emplName;
}

void setEmplNumber(int n)
{
	emplNumber = n;
}

int getEmplNumber()
{
	return emplNumber;
}

void setHireDate(int d)
{
	hireDate = d;
}

int getHireDate()
{
	return hireDate;
}

}; 
#endif 


here's the second header
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
#ifndef PRODUCTIONWORKER_H
#define PRODUCTIONWORKER_H
#include "employee.h"					// Needed for the employee class.
#include <iostream>
using namespace std;

class productionWorker
{
private:
	int shift;
	double hourlyPayRate;

public:
	productionWorker(int s, double hpr)
	{
		shift = s;
		hourlyPayRate = hpr;
	}

	// "Set" and "Get" the Shift function.
	void setShift();
	int getShift() const;

	// "Set" and "Get" the Hourly Pay Rate function.
	void setHourlyPayRate();
	double getHourlyPayRate() const;

void setShift(int s)
{
	shift = s;
}

int getShift()
{
	return shift;
}

void setHourlyPayRate(double hpr)
{
	hourlyPayRate = hpr;
}

double getHourlyPayRate()
{
	return hourlyPayRate;
}

};
#endif 


and the main 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
#include "employee.h"
#include "productionWorker.h"
#include <string>
#include <iomanip>
#include <iostream>
using namespace std;

int main ()
{
	char response;
	const int SIZE = 100;
	string name[SIZE];
	int number, date, shift;
	double payRate;

	do
	{
		// Ask the user for the employee's name.
		cout << "What is the employee's name?" << endl;
		cin >> name[SIZE];
	
		// Ask the user for the employee's number.
		cout << "\nWhat is the employee's number?" << endl;
		cin >> number;
	
		// Ask the for the employee's hire date.
		cout << "\nWhat is the employee's hire date?\n";
		cout << "(Please enter the month, day, and year \n";
		cout << " without any slashes, dashes, commas, or other punctuation.)\n";
		cout << "For example, January 14, 1983 would look like 01141983. " << endl;
		cin >> date;
	
		// Ask for what shift the employee is working.
		cout << "\nWhat shift does the employee work? Shift 1, or Shift 2?" << endl;
		cin >> shift;
		if(shift < 0 || shift > 2)
		{
			cout << "An error occurred, please enter only 1 or 2 as a shift number." << endl;
			cin >> shift;
		}
	
		cout << "\nHow much does the employee make per hour? " << endl;
		cin >> payRate;



		// Create the Production Worker class object.
		productionWorker in(shift, payRate);

		// Create the Employee class object.
		employee into(name[SIZE], number, date);

		// Display the employee data.
		cout << "\n\n----------Here is the employee's data:----------\n\n";
		cout << "	Employee's Name:			" << into.getEmplName() << endl;
		cout << "	Employee's Number:			" << into.getEmplNumber() << endl;
		cout << "	Employee's Hire Date:		" << into.getHireDate() << endl;
		cout << "	Employee's Shift:			" << in.getShift() << endl;
		cout << "	Employee's Hourly Pay Rate: $" << setprecision(2) << fixed << in.getHourlyPayRate() << endl << endl;


		// Ask the user if they would like to rerun the program.
		cout << endl << "\nWould you like to run the program again?" << endl;
		cin >> response;
		cout << endl;

	} while (response == 'y' || response == 'Y');

	return 0;
}
wait, i think i kinda fixed the first part, where it asks for the employee's name. I got rid of the array and just kept it as a string, but whenever I put a space when I run it, it goes through the whole program then suddenly exits out.
ALRIGHT! SO I got the whole thing to work, it displays the employee's data at the end even!
BUT I can't put spaces in the string... It does what i mentioned earlier. This means I can't put in the employee's first name and last name.... Any ideas?

I'm gonna put in the cin.getline cstring, but i don't think that works too well with strings?

Thanks for any and all help, in advance!
Get the entire line then parse it yourself. Look into the substr and find members of std::string.
Topic archived. No new replies allowed.