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;
}
|