standard deviation error

im sure this is a very rookie mistake, but it says there's a linker error with an undefined reference to sum(double,int)
and a Id return 1 exit status. i checked my function and everything but im not sure what's wrong with it. can someone please tell me how i can fix this problem





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
#include <fstream>
#include <cmath>
#include <iostream>
#include <stdlib.h>
using namespace std;


double sum(double the_standard_Deviation[], int size);


int main ()
{
	ifstream inputfile;
	double N;

        //some random number...
	int size;
	const int Num_List = 1000;
	double summ;//, avg;

	inputfile.open("program8.txt");
	if(inputfile.fail())
	{
		cout << "Error: could not open program8.txt" << endl;
		exit (EXIT_FAILURE);
	}




	double standDeviation [Num_List];

	inputfile >> N;
	while(!inputfile.eof() && (size < Num_List))
	{
                //Using size here with that random number in place == Bad Stuff Will Happen
		standDeviation[size] = N;
		size++;
		cout<< N<<endl;
		inputfile >> N;
	}
	summ = sum(standDeviation, size);
	cout<< "SUM: "<< N << " " << size << " " << summ << endl;

	cout.setf(ios::fixed);
	cout.setf(ios::showpoint);
	cout.precision(3);
 
	inputfile.close();

	system("Pause");
	return 0;
}




Last edited on
Where's the definition of sum()?
summ = sum(standDeviation, size);


isn't that the definition of sum?
well...isn't summ declared and everything? so wouldn't hat mean the definition of sum() is there?
That function is missing its body
That's a call to sum().

This is a function declaration:
double sum(double the_standard_Deviation[], int size);
This is a function definition:
1
2
3
double sum(double the_standard_Deviation[], int size){
    //...
}
Topic archived. No new replies allowed.