Finding the highest number

Hello everyone, I am having an issue with compiling my program. The function that won't compile is supposed to find the highest expense. The compile error code is: undefined reference to `highestExpense(double*, int&). Everything looks right to me. Everything worked fine prior to the function highestCharge. Can someone help me spot out the problem. Thank you.

Here is part of my main:
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
  int main()	
{
	//VARIABLES
	int cnt = 0;								// counter used for employee coverage
	int cnt1 = 0;								// second counter used for family coverage
	double empAverage;							// return value from the called function averageExpense for employee average
	double famAverage;  						// return value from the called function averageExpense for family average
	double empHighest;							// return value from the called function highestExpense for employee average
	double famHighest;							// return value from the called function highestExpense for family average
	
	// opening the text file medical.txt
	ifstream inMedicalData;						
	inMedicalData.open(IN_MED_FILE.c_str());
	
	// array's
	double emp [MAX_ARRAY];
	double fam [MAX_ARRAY];
	
	// display header
	display_header();
  	// verification that file exists 
    if (!inMedicalData)
    {	   
       cout << "The input data file does not exist!" << endl;
       cout << "Please verify input file and run the program again!" << endl;
       return 5;
    }
	// calling different functions to compute and display the results   	
	else
	{
		cout << "File opened successfully! Reading file." << endl << endl;
		readMedicalFile (inMedicalData, emp, fam, cnt, cnt1); 
		
		// functions to compute the average expenses
		empAverage = averageExpense (emp, cnt);
		famAverage = averageExpense (fam, cnt1);
		
		//functions to compute the highest expenses	
		empHighest = highestExpense (emp, cnt);
		famHighest = highestExpense (fam, cnt1);
		
		//functions to display the results
		displayExpenses (empAverage, EMP_NAME, cnt);
		cout << endl;
		displayExpenses (famAverage, FAM_NAME, cnt1);	
	}	
	return 0;
}


Here is my function:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
   double highestCharge (double avg [], int& count)
{
	double highest = 0;
	int cell;
	
	for (cell = 0; cell <= count; cell++)
	{
		if (avg[cell] > highest)
			highest = avg[cell];
	}
		
//	cout << "Highest value is " << highest << endl;
	
	return highest;
}

Last edited on
Sorry guys for not taking more time to look at it. It was a very minor mistake, My function name was highestCharge; whereas my prototype is called highestExpense. I knew that was it so I changed it and all is good.
Topic archived. No new replies allowed.