linker error and combine functions?

I started a program that calculates an employee's weekly gross pay when the user inputs hours worked and hourly pay rate. With what I have so far, it compiles fine, but gives these errors:

on Dev-C++:
message: [Linker error] undefined reference to 'get_pay(float, float)'
Id returned 1 exit status
file: message: [Build Error][grossPay.exe] Error 1

on Visual Studio 2005:
1>------ Build started: Project: grossPay, Configuration: Debug Win32 ------
1>grossPay.obj : error LNK2019: unresolved external symbol "void __cdecl get_pay(float,float)"

How do I resolve this linker error? And also, how would I add if/else statements for the following condition? If the employee's weekly gross pay is more than $200 (personal exemption), then the employee pays 12% federal tax and 5% state tax from his taxable income (gross pay - exemption). I'd also like to combine the functions I have so that taxable income, fed tax, and state tax are all calculated in the same function.

Here's what I have:


using namespace std;

void get_pay(float wage, float hours);
float calc_gross_pay(float wage, float hours);
float calc_net(float gross, float deduct);
void print_gross_pay(float);
void print_net(float);

int main(int argc, char *argv[])
float wage,hours,gross,deduct,sum;

get_pay(wage, hours);
gross = calc_gross_pay(wage, hours);
sum = calc_net(gross, deduct);

return 0;

void get_pay(float& wage, float& hours)
cout << "Enter your hourly wage: ";
cin >> wage;
cout << "Enter your hours worked: ";
cin >> hours;

float calc_gross_pay(float wage, float hours)
return wage * hours;

float calc_net(float gross, float deduct)
return gross - deduct;

void print_gross_pay(float gross)
cout << "Your gross pay is: " << gross;

void print_net(float sum)
cout << "Your net pay is: " << sum;


  • There's nothing wrong I can see with your program. get_pay is prototyped and the body is provided.

  • the prototype provided was for
    void get_pay(float wage, float hours);
    but the definition provided was for
    void get_pay(float & wage, float & hours)
    try to add such operator '&' in the prototype

    for your if-statement question
    my advice is to read any book in C, C++, or even JAVA
    if-statements are very similar in these languages

    see ya
    Mohammad Nasim
  • Thank you for the prototype advice! It worked and I'm making some progress on the if else statements.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!