C++ Class Linker Error Code
I am writting this basic program and am stuck. I am new to C++ here is my
code.
This program will do the following:
1.calulate a fine for various offenses
It will accomplish this by:
1.The user will input the actual speed, speed limit, wether the
offense occured in a work zone/ residential area/ or not, and the court fees
2.Display the total amount for the ticket
3.Prompt the user if they wish to enter another ticket or quit
Speeding
Fine: $5 per mile over speed limit plus Court Fees
Speeding Highway Work Zone
Fine: $6 per mile over speed limit plus Court Fees
Speeding in a Residential District
Fine: $7 per mile over speed limit plus $200 plus Court Fees
*/
#include <iostream>;
class FineCalculator
{
public:
~FineCalculator() {}
FineCalculator(int courtFees);
int getFine(int zone, int speedLimit, int actualSpeed) const;
private:
int courtFees;
int balance;
};
FineCalculator::FineCalculator(int courtFees)
{
//return courtFees;
}
int getFine(int zone, int speedLimit, int actualSpeed)
{
//define IF you are speeding or not
if (actualSpeed > speedLimit)
{
/* define speeding zones
1. Regular
2. Highway
3. Residential
*/
if (zone==1)
{
int balanceCounter=actualSpeed-speedLimit;
//balance=courtfees+(loopcounter*5)
//balance
}
}
return 0;
}
int main()
{
int courtFee=0;
int inputFee=0;
int accumulator=0;
int programLooper=1;
int speedLimitz=0;
int vechicleSpeed=0;
std::cout<<"Please enter the court fee $";
std::cin >>courtFee;
FineCalculator fine1(courtFee);
while (programLooper !=0)
{
//1 for regular, 2 for highway, 3 for residential
//loop selection of offenses
std::cout<<"Please make numerical ticket selection for where the
offense occured: \n";
std::cout<<"1. Regular \n";
std::cout<<"2. Highway \n";
std::cout<<"3. Residential \n";
std::cin >>programLooper;
std::cout<<"\n \n \n";
std::cout<<"Please Enter the speed limit \n";
std::cin >>speedLimitz;
std::cout<<"\n \n \n";
std::cout<<"Please Enter the vechile speed \n";
std::cin >>vechicleSpeed;
fine1.getFine(programLooper,speedLimitz,vechicleSpeed);
}
if (programLooper==0)
{
//end program loop
return (0);
}
}
For starters on the FineCalculator::FineCalculator(int courtFees) method I
am not sure what to type in the return because anything after return I
type gives an error.
Also on the fine1.getFine(programLooper,speedLimitz,vechicleSpeed); I
get an error saying :
Error 2 error LNK1120: 1 unresolved externals
Error 1 error LNK2019: unresolved external symbol "public: int
__thiscall FineCalculator::getFine(int,int,int)const "
(?getFine@FineCalculator@@QBEHHHH@Z) referenced in function _main
What is going on here? I am completely stumped.
No comments:
Post a Comment