Doing assignment for class. Getting this error message:
1>------ Build started: Project: Mulvihill_Program_7, Configuration: Debug Win32 ------
1>Mulvihill_Program_7.obj : error LNK2019: unresolved external symbol "double __cdecl calcGross(void)" (?calcGross@@YANXZ) referenced in function _main
1>c:\users\pat\documents\visual studio 2012\Projects\Mulvihill_Program_7\Debug\Mulvihill_Program_7.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Here is the code:
#include<iostream>
using namespace std;
int getHoursWorked();
double getPayRate();
double calcGross();
int hoursWorked = 0;
double payRate = 0.0;
double grossPay = 0.0;
double OVERTIME = 1.5;
double overTimePayRate = 0.0;
double pay = 0.0;
int main()
{
getHoursWorked();
getPayRate();
pay = calcGross();
cout<<pay;
}
int getHoursWorked()
{
cout<<"Enter the amount of hours worked ";
cin>>hoursWorked;
return(hoursWorked);
}
double getPayRate()
{
cout<<"How much do you make an hour? ";
cin>>payRate;
return(payRate);
}
double calcGross(int hoursWorked, double payRate)
{
if (payRate < 40)
{
grossPay = hoursWorked * payRate;
}
else
{
overTimePayRate = OVERTIME * payRate;
grossPay = hoursWorked * overTimePayRate;
}
return(grossPay);
}
I know there's probably a lot more wrong with this code than just the error in terms of conventions, and stuff, but I'm new at this, and I'm just trying to understand the error message for now.
The linker cannot find this function definition,
because you define the function as such,
Should you remove the parameters so that the function declaration & definition are matched. Change your function declaration like this,
Then pass the value of
hoursWorked
&payRate
when calling it inmain()