Error LNK2019
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: Error LNK2019

  1. #1
    Join Date
    Nov 2009

    Error LNK2019

    I have the following code:
    # include <iostream>
    # include <iomanip>
    using namespace std;
    using std::cin;
    using std::cout;
    using std::endl;

    //function prototypes
    double calcAverage (double, double, double);
    void getTestScore(double&, double&, double&);
    void displayAverage (double);

    int main ()
    double score_1 = 0.0;
    double score_2 = 0.0;
    double score_3 = 0.0;
    double average = 0.0;

    //get score inputs from getTestScores
    getTestScore(score_1, score_2, score_3);

    //calculate average
    average = calcAverage (score_1, score_2, score_3);

    //display average
    displayAverage (average);

    return 0;

    //**********function definitions**********

    //getTest Scores
    void getTestScore(double& score_1, double& score_2, double& score_3)
    cout << "Enter score 1:" << endl;
    cin >> score_1;
    cout << "Enter score 2:" << endl;
    cin >> score_2;
    cout << "Enter score 3:" << endl;
    cin >> score_3;
    }//end getTestScore

    double calcAverage (double& score_1, double& score_2, double& score_3)
    double average = 0.0;
    average = (score_1 + score_2 + score_3) / 3.0;
    return average;
    }//end calcAverage

    void displayAverage (double& avgerage)
    cout << "The average is " << avgerage <<"." <<endl;
    }//end displayAverage

    I am getting the errors:
    error LNK2019: unresolved external symbol "void __cdecl displayAverage(double)" (?displayAverage@@YAXN@Z) referenced in function _main


    error LNK2019: unresolved external symbol "double __cdecl calcAverage(double,double,double)" (?calcAverage@@YANNNN@Z) referenced in function _main

    I am relatively new to C++ and do not know how to fix this error.

  2. #2
    Join Date
    Feb 2005

    Re: Error LNK2019

    Please use code tags!

    You're declaring:

    void displayAverage (double);
    but your implementation is:
    void displayAverage (double& avgerage)
    Your declaration doesn't match your implementation. Change one or the other so they match.

    With this knowledge, I'll bet you can figure out the other.

  3. #3
    Join Date
    Nov 2009

    Re: Error LNK2019

    That fixed it. Thanks for your help and sorry about the code tags. It was my first time posting and didn't know about them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)