I've been struggling with this for the last two hours, not sure what I'm missing. I've searched the forums and used Google, but can't find an answer that I understand. I'm getting the following error messages when compiling:
[Linker error] undefined reference to `getScore(float&, int&)'
[Linker error] undefined reference to `calcAverage(float, int)'
[Linker error] undefined reference to `findLowest(float, int)'
ld returned 1 exit status
We've just learned about functions in class, so I'm sure I've made a few mistakes. Some of the code for the functions are incomplete, as well, because I can't get beyond this.
Any help would be appreciated.
Here's my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
#include <iostream>
#include <conio.h>
using namespace std;
void getScore(float &, int &);
void calcAverage(float, int);
float findLowest(float, int);
int main()
{
int flag = 0;
do {
int size = 0;
float grade[size];
getScore(grade[size], size);
calcAverage(grade[size], size);
cout << "\n\nTry again?" << endl;
cout << "Enter 1 for yes or 0 for no!" << endl << endl;
cout << "Selection: ";
cin >> flag;
} while (flag != 0);
if (flag >= 1)
{
system("CLS");
}
else
{
system("CLS");
cout << "Program shutting down..." << endl;
}
cout << endl;
system("pause");
return 0;
}
void getScore(float grade[], int &size)
{
int flag;
do {
for (;;)
{
system("CLS");
cout << "Enter a grade to be averaged or input -99 to finish: " << endl << endl;
cout << "Grade: " << endl << endl;
if (cin >> grade[size])
{
break;
}
else
{
system("CLS");
cout << "**Please enter a valid grade or -99 to finish!\n" << endl;
cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
}
size++;
} while (flag != -99);
}
void calcAverage(float grade[], int size)
{
float least;
float sum;
float avg;
least = findLowest(grade[size], size);
}
float findLowest(float grade[], int size)
{
int counter = 0;
float least = 100;
for(counter = 0; counter < size; counter++)
{
if(grade[counter] < least)
{
least = grade[counter];
}
}
return least;
}
|