Dec 16, 2013 at 4:22pm UTC
Been fighting this for about an 2 hours now and could use a little help please...getting these errors:
payroll.cpp(10): error C2062: type 'double' unexpected
payroll.cpp(19): error C2065: 'rate' : undeclared identifier
payroll.cpp(26): error C2065: 'grosspay' : undeclared identifier
payroll.cpp(26): error C2065: 'rate' : undeclared identifier
payroll.cpp(27): error C2065: 'grosspay' : undeclared identifier
#include <iostream>
using namespace std;
double crate, chours, cgpay;
double calcgpay (double crate, double chours);
void prtgpay (double catchgpay);
int cstudid;
int main() {
int studid, supid, hours,
double grosspay, rate;
cout<< "Enter Student ID#: ";
cin>> studid;
cout<< "Enter Supervisor's ID#: ";
cin>> supid;
cout<< "Enter Students hourly pay: ";
cin>> rate;
cout<< "Enter hours worked: ";
cin>> hours;
//call
grosspay = calcgpay (rate, hours);
prtgpay (grosspay);
system ("PAUSE");
return 0;
}
double calcgpay (double crate, int chours, double cgpay ){
double gpay;
gpay = crate * chours;
return gpay;
}
void prtgpay (double catchgpay){
cout<< "Student "<< cstudid << "Pay Rate "<< crate << "Hours worked " << chours << "Gross Pay" << catchgpay <<endl;
}
Last edited on Dec 16, 2013 at 4:31pm UTC
Dec 16, 2013 at 4:30pm UTC
int studid, supid, hours,
you need a semi-colon at the end . NOT a comma.
use code tags too :)
edit:
1>k:\c++\payroll\payroll\payroll.cpp(10 ): error C2062: type 'double' unexpected
The compiler tells you the line (or fairly near to) where things are not right.
Last edited on Dec 16, 2013 at 4:31pm UTC
Dec 16, 2013 at 4:34pm UTC
code tags?
like this?
//call
and many thanks.
Dec 16, 2013 at 5:14pm UTC
got it, thanks. Fixed the @#%$& semi colon. Hate that, makes me feel like a moron. Now I have
error LNK2019: unresolved external symbol "double __cdecl calcgpay(double,double)" (?calcgpay@@YANNN@Z) referenced in function _main
fatal error LNK1120: 1 unresolved externals
Having a really time grasping functions...can't seem to find an explanation that's making them click for me. any help is extremely appreciated.
Dec 16, 2013 at 5:18pm UTC
You've declared calcgpay to take two parameters:
double calcgpay (double crate, double chours);
and you're calling it with two parameters:
grosspay = calcgpay (rate, hours);
However, your definition has three parameters:
double calcgpay (double crate, int chours, double cgpay ){
So the linker is looking for a function called calcgpay that takes two parameters, but can't find a definition for such a function, because there isn't one.
Dec 16, 2013 at 5:30pm UTC
Got it to run. Still needs some tweaking, but I think I'm out of the weeds now, Thanks a lot guys!!!!