Hello. I am receiving two error messages that both include "unresolved externals." My goal is basically to use functions to read data from a file, sum it, then average it. Does anyone see the problem? Here is my code:
#include <iostream>
#include <fstream>
using namespace std;
void ReadAndSum(ifstream&, int&, float&);
// Reads, counts, and averages values on a file.
int main ()
{
ifstream dataFile;
int numberOfValues;
float average;
cout << fixed << showpoint;
dataFile.open("Averages.dat");
ReadAndSum(dataFile, numberOfValues, average);
cout << "The average of " << numberOfValues
<< " values is " << average << endl;
return 0;
}
//*************************************************
void ReadAndSum (int data, int number, float avg)
// Function Definition
{
float sum;
sum = 0;
The problem is that the prototype void ReadAndSum(ifstream&, int&, float&); differs from the actual implementation void ReadAndSum (int data, int number, float avg).
So the linker is looking for that function with '&' but there's none
Thank you very much. I think I am beginning to understand. So, the error is because I am not including the ampersand in the function definition? I just added them and I am still receiving the same error.