Like Tree1Likes
  • 1 Post By Lesshardtofind

linker error

This is a discussion on linker error within the C++ Programming forums, part of the General Programming Boards category; Hey, can anyone help me figure out why I keep getting a "linker error" when running this program? the error ...

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    10

    linker error

    Hey, can anyone help me figure out why I keep getting a "linker error" when running this program?
    the error is- [Linker error] undefined reference to `billingamount(double, double, bool)'

    Code:
    #include <iostream>
    #include <iomanip>
    
    
    using namespace std;
    
    
    double billingamount(double hourlyrate, double contime, bool incomestatus);
    
    
    int main()
    {
        double income;
        double hourlyrate;
        double contime;
        bool incomestatus;
        
        cout <<"Enter income: ";
        cin >> income;
        cout << endl;
        
        if(income<=25000)
        incomestatus=1;
        else 
        incomestatus=0;
        
        cout << "Enter the hourly rate: ";
        cin >> hourlyrate;
        cout <<endl;
        
        cout <<"Enter the total consulting time in minutes: ";
        cin >> contime;
        cout << endl;
        
        cout << fixed << showpoint <<setprecision(2)<<endl;
        
        cout <<"the billing amount is $" << billingamount(hourlyrate,contime,incomestatus) << endl;
        
        system("pause");
        return 0;
    }
    
    
    double billingamout(double hourlyrate, double contime, bool incomestatus)
    {
           double charges;
           
           if (incomestatus)
           if(contime<=30)
           charges=0.0;
           else
           charges=hourlyrate*0.4*(contime-30)/60;
           else if(contime<=20)
           charges=0.0;
           else 
           charges=hourlyrate*0.7*(contime-20)/60;
           return charges;
    }

  2. #2
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    407
    You mispelled billing amount in your definition. Missed an n.

    Future reference all the clues are in your error. If it says undefined reference then you need to look at your definition and see what's different.
    Last edited by Lesshardtofind; 11-05-2012 at 12:41 PM.
    Salem likes this.

  3. #3
    Registered User
    Join Date
    Nov 2012
    Posts
    10
    Argh! Thank you! I read and re-read all 3 of those lines looking for the spelling mistake. I must have been looking for too long. lol Thanks

  4. #4
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    407
    If in doubt just copy and paste the definition. Lol

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linker Error
    By abhishekcoder in forum C Programming
    Replies: 4
    Last Post: 01-26-2012, 09:34 AM
  2. Linker Error
    By herWter in forum C++ Programming
    Replies: 11
    Last Post: 08-10-2008, 06:22 AM
  3. Linker Error
    By guitarist809 in forum Windows Programming
    Replies: 1
    Last Post: 07-22-2008, 11:17 PM
  4. Linker error in C
    By walataza in forum C Programming
    Replies: 17
    Last Post: 03-12-2008, 07:03 PM
  5. linker error
    By floxn in forum C++ Programming
    Replies: 4
    Last Post: 09-15-2005, 01:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21