2015-02-28 10 views
-2

Эй, ребята и девочки, мне нужна серьезная помощь. У меня есть этот финал и его срок в 2 дня и несколько часов. Однако я не могу разрешить эту ошибку lnk2001 в конце моей программы. Пожалуйста, помогите мне. Я не знаю, как решить. Я оставил желания инструкторов в кодировке в качестве комментариев.Не могу избавиться от ошибки lnk2001

#include <iostream> 
#include <string> 
#include <iomanip> 

using namespace std; 
using std::cout; 
using std::cin; 
using std::endl; 


// 
//CLASS DECLARATION SECTION 
// 
class EmployeeClass { 
public: 
void ImplementCalculations(string EmployeeName, double hours, double wage); 
void DisplayEmployInformation(void); 
static double Addsomethingup(EmployeeClass, EmployeeClass, EmployeeClass); 
string EmployeeName; 
double hours; 
double wage; 
double basepay; 
double overtime_hours; 
double overtime_pay; 
double overtime_extra; 
static double iTotal_salaries; 
static double iIndividualSalary; 
static double iTotal_hours; 
static double iTotal_OvertimeHours; 
}; 

int main() 
{ 
system("cls"); 

cout << "Welcome to the Employee Pay Center" << endl; 

/* 
These are my three employees 
*/ 
EmployeeClass Employ1; 
EmployeeClass Employ2; 
EmployeeClass Employ3; 


/* 
Here you will prompt for the first employee’s information. 
Prompt the employee name, hours worked, and the hourly wage. For each piece      
of information, you will update the appropriate class member defined above. 
Example of Prompts 
Enter the employee name  = 
Enter the hours worked  = 
Enter his or her hourly wage = 
*/ 
cout << "Enter the employee name." << endl; 
cin >> Employ1.EmployeeName; 
cout << "Enter the hours worked." << endl; 
cin >> Employ1.hours; 
cout << "Enter his or her hourly wage." << endl; 
cin >> Employ1.wage; 


/* 
Here you will prompt for the second employee’s information. 
Prompt the employee name, hours worked, and the hourly wage. For each piece 
of information, you will update the appropriate class member defined above. 
Enter the employee name  = 
Enter the hours worked  = 
Enter his or her hourly wage = 

*/ 
cout << "Enter the employee name." << endl; 
cin >> Employ2.EmployeeName; 
cout << "Enter the hours worked." << endl; 
cin >> Employ2.hours; 
cout << "Enter his or her hourly wage." << endl; 
cin >> Employ2.wage; 

/* 
Here you will prompt for the third employee’s information. 
Prompt the employee name, hours worked, and the hourly wage. For each piece 
of information, you will update the appropriate class member defined above. 
Enter the employee name  = 
Enter the hours worked  = 
Enter his or her hourly wage = 

*/ 
cout << "Enter the employee name." << endl; 
cin >> Employ3.EmployeeName; 
cout << "Enter the hours worked." << endl; 
cin >> Employ3.hours; 
cout << "Enter his or her hourly wage." << endl; 
cin >> Employ3.wage; 


/* 
Here you will implement a function call to implement the employ calcuations 
for each object defined above. You will do this for each of the three 
employees or objects. 
The format for this step is the following: 
[(object name.function name(objectname.name, objectname.hours, 
objectname.wage)] ; 
*/ 
Employ1.ImplementCalculations(Employ1.EmployeeName, Employ1.hours, 
Employ1.wage); 
Employ2.ImplementCalculations(Employ2.EmployeeName, Employ2.hours, 
Employ2.wage); 
Employ3.ImplementCalculations(Employ3.EmployeeName, Employ3.hours, 
Employ3.wage); 
EmployeeClass::Addsomethingup(Employ1, Employ2, Employ3); 

} 
/* 
This section you will send all three objects to a function that will add up 
the the following information: 
- Total Employee Salaries 
- Total Employee Hours 
- Total Overtime Hours 

The format for this function is the following: 
- Define a new object. 
- Implement function call [objectname.functionname(object name 1, object 
name 2, object name 3)] 
/* 

} //End of Main Function*/ 


void EmployeeClass::ImplementCalculations (string EmployeeName, double 
hours, double wage){ 
//Initialize overtime variables 
    basepay = wage; 
overtime_hours=0.0; 
overtime_pay=0.0; 
overtime_extra=0.0; 

if (hours > 40) 
{ 
    EmployeeClass::hours = 40.0; 
    EmployeeClass::overtime_hours = hours - 40; 
    EmployeeClass::overtime_pay = wage * 1.5; 
    EmployeeClass::overtime_extra = overtime_hours * overtime_pay; 
    EmployeeClass::iIndividualSalary = overtime_extra + (wage * 
EmployeeClass::hours); 



    /* 
    This section is for the basic calculations for calculating overtime pay. 
    - base pay = 40 hours times the hourly wage 
    - overtime hours = hours worked – 40 
    - overtime pay = hourly wage * 1.5 
    - overtime extra pay over 40 = overtime hours * overtime pay 
    - salary = overtime money over 40 hours + your base pay 
    */ 

    /* 
    Implement function call to output the employee information. Function is 
defined below. 
    */ 

} 


else 
{ 
    EmployeeClass::hours = hours; 
    EmployeeClass::overtime_hours = 0.0; 
    EmployeeClass::overtime_pay = 0.0; 
    EmployeeClass::overtime_extra = 0.0; 
    EmployeeClass::iIndividualSalary = wage * EmployeeClass::hours; 

    /* Here you are going to calculate the hours less than 40 hours. 
    - Your base pay is = your hours worked times your wage 
    - Salary = your base pay 
    */ 

    /* 
    Implement function call to output the employee information. Function is 
defined below. 
    */ 

} // End of the else 

DisplayEmployInformation(); 

} //End of Primary Function 
void EmployeeClass::DisplayEmployInformation(void) 
{ 
// This function displays all the employee output information. 
//This is your cout statements to display the employee information: 
cout << "Employee Name ............. =" << EmployeeName << endl; 
cout << "Base Pay .................. =" << basepay << endl; 
cout << "Hours in Overtime ......... =" << overtime_hours << endl; 
cout << "Overtime Pay Amount........ =" << overtime_pay << endl; 
cout << "Total Pay ................. =" << iIndividualSalary << endl; 


} // END OF Display Employee Information 

double EmployeeClass::Addsomethingup(EmployeeClass Employ1, EmployeeClass 
Employ2, EmployeeClass Employ3) 
{ 
Employ1.DisplayEmployInformation(); 
// Adds two objects of class Employee passed as 
// function arguments and saves them as the calling object's data member 
values. 
EmployeeClass::iTotal_hours = Employ1.hours + Employ2.hours + Employ3.hours; 
double myhours; 
EmployeeClass::iTotal_hours = Employ1.hours + Employ2.hours + Employ3.hours; 
myhours = Employ1.hours + Employ2.hours + Employ3.hours; 
EmployeeClass::iTotal_OvertimeHours = Employ1.overtime_hours + 
Employ2.overtime_hours + Employ3.overtime_hours; 
EmployeeClass::iTotal_salaries = Employ1.iIndividualSalary + 
Employ2.iIndividualSalary + Employ3.iIndividualSalary; 
/* 
Add the total hours for objects 1, 2, and 3. 
Add the salaries for each object. 
Add the total overtime hours. 
*/ 


// Then display the information below. 
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " << endl; 
cout << "%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%% " << endl; 
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " << endl; 
cout << "%%%% Total Employee Salaries ..... = " << iTotal_salaries << endl; 
cout << "%%%% Total Employee Hours ........ = " << iTotal_hours << endl; 
cout << "%%%% Total Overtime Hours......... = " << iTotal_OvertimeHours << 
endl; 
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " << endl; 
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " << endl; 

return 0; 

} // End of function 

ответ

0

Не целочисленные статические переменные-члены должны быть определены вне определения класса.

class EmployeeClass 
{ 
    // ... 

    static double iTotal_salaries; 
    static double iIndividualSalary; 
    static double iTotal_hours; 
    static double iTotal_OvertimeHours; 
}; 

double EmployeeClass::iTotal_salaries = 0.0; 
double EmployeeClass::iIndividualSalary = 0.0; 
double EmployeeClass::iTotal_hours = 0.0; 
double EmployeeClass::iTotal_OvertimeHours = 0.0; 
+0

ОН МОЙ БОГ !!!!!! Огромное спасибо! Вы мой спаситель! –

 Смежные вопросы

  • Нет связанных вопросов^_^