我不明白为什么这不会运行。我应该存储hours * payrate
在工资数组中,然后showResults
获取此信息cout
。我运行它时得到的错误是
error LNK2019: unresolved external symbol "void __cdecl showResults(int * const,int,double * const,double * const,double * const)" (?showResults@@YAXQAHHQAN11@Z) referenced in function
error LNK2019: unresolved external symbol "void __cdecl getEmployeeData(int * const,int,double * const,double * const,double * const)" (?getEmployeeData@@YAXQAHHQAN11@Z) referenced in function `_main`
下面的代码:
#include <iomanip>
#include <iostream>
using namespace std;
void getEmployeeData(int[], int, double[], double[], double[]);
void showResults(int[], int, double[], double[], double[]);
int main()
{
const int ARRAY_SIZE = 7;
int empId[ARRAY_SIZE] = {565, 845, 452, 130, 789, 758, 877};
double hoursWorked[ARRAY_SIZE]; // Holds hours worked
double payrate[ARRAY_SIZE]; // Holds pay rate
double wages[ARRAY_SIZE]; // Holds wages
getEmployeeData(empId, ARRAY_SIZE, payrate, hoursWorked, wages);
showResults(empId, ARRAY_SIZE, payrate, hoursWorked, wages);
system("pause");
return 0;
}
void getEmployeedata(int nums[],int size,double pay[],double hours[],
double wages[])
{
//Hours worked and Pay rate
for(int index = 0; index < size; index++)
{
cout << "Enter number of hours worked by employee number "
<< nums[index] << ": ";
cin >> hours[index];
cout << "\nEnter hourly pay rate ";
cin >> pay[index];
wages[index] = hours[index] * pay[index];
}
}
void showResults(int nums[], int size, double pay, double hours, double wages[])
{
for(int index = 0; index < size; index++)
{
cout << "Employee Number Gross Wage " << endl
<< nums[index] << " " << wages[index];
}
}