unresolved external

why the compiler show this error to me?


Error 1 error LNK2019: unresolved external symbol "double __cdecl calculatecharge(double)" (?calculatecharge@@YANN@Z ) referenced in function _wmain F:\university\mabani computer\takalif\programs\mary\mary\mary.obj











#include "stdafx.h"
#include<iostream>
#include<iomanip>
using namespace std;
double calculatecharge(double);

;int _tmain(int argc, _TCHAR* argv[])
{
double hour1,hour2,hour3,totalhours=0,totalcharge=0;

cout<<"Enter 3 number as hours:";
cin>>hour1>>hour2>>hour3;

cout<<"\n"<<"car"<<setw(12)<<"hours"<<setw(12)<<"charge\n";

totalhours=hour1+hour2+hour3;

cout<<"1"<<setw(12)<<hour1<<setw(12)<< calculatecharge(hour1)<<"\n";
cout<<"2"<<setw(12)<<hour2<<setw(12)<< calculatecharge(hour2)<<"\n";
cout<<"3"<<setw(12)<<hour3<<setw(12)<< calculatecharge(hour3)<<"\n";

totalcharge=calculatecharge(hour1)+calculatecharge(hour2)+calculatecharge(hour3);

cout<<"TOTAL"<<setw(8)<<totalhours<<setw(12)<<totalcharge<<"\n";


return 0;

}
double calculatecharge(double charge,double hour,double x)
{

if(hour<3 && hour>0)

{
charge=2.00;
}

else

if(hour==24)
{
charge=10.00;
}

else

{
x=ceil(hour)-3;
charge=x*0.5+2;
}

return charge;
}
You've defined this function:
double calculatecharge(double charge,double hour,double x)
It requires three parameters.

But in function main() you call a function calculatecharge(hour1) which takes a single parameter.

It looks like you don't actually need those three parameters, so change the function definition to use just double hour as a parameter and make the others local variables defined inside the function.
thank you so much
Topic archived. No new replies allowed.