Undefined reference error

I have written a code using parallel arrays to display 20 bottles of bourbon and the corresponding number of bottles sold. The program also outputs the highest and lowest selling bottles of the month. I am running into the problem of getting an undefined reference to 'getTotal(int*,int)'. How would I go about fixing this problem so that my program will compile? Also, is there an easier way to produce a table with the names of the bottles and the sales? Thank you for the help!

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
101
102
103
104
105
106
107
108
109
110
111
  #include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <cstdlib>

using namespace std;


// Function prototypes
int getTotal(int [], int);

int posOfSmallest(int [], int);

int posOfLargest(int [], int);

int main()
{
    const int NUM_TYPES = 20;
    int sales[NUM_TYPES];
    string name[NUM_TYPES] = {"Pappy Van Winkle", "Woodford Reserve", "Blanton's", "Maker's Mark", "Booker's", "Knob Creek",
                              "Buffalo Trace Distillery", "Elijah Craig", "Bulleit", "Basil Hayden's", "Eagle Rare" ,
                              "1792", "Angel's Envy", "Wild Turkey", "Four Roses", "Willett", "Jefferson's" , "Baker's",
                              "Evan William's", "Larceny"};

    // Create the arrays for the names and sales amounts

    int totalBottlesSold, highSellingProduct, lowSellingProduct;

    // Input the number of bottles sold

	for (int type = 0; type < NUM_TYPES; type++)
	{
		cout << "Bottles sold last month of " << name[type] << ": ";
      	cin  >> sales[type];

		while (sales[type] < 0)
		{	cout << "Bottles sold must be 0 or more.  Please re-enter the number of bottles sold: ";
		    cin  >> sales[type];
		}
	}

	 // Call functions to get total sales and high and low selling bottles
    totalBottlesSold  = getTotal(sales, NUM_TYPES);

    lowSellingProduct = posOfSmallest(sales, NUM_TYPES);

    highSellingProduct = posOfLargest(sales, NUM_TYPES);

   // Produce the sales report
   cout << endl << endl;
   cout << "     Bourbon Bottle Sales Report \n\n";
   cout << "Name              Bottles Sold \n";
   cout << "____________________________\n";


	   cout << name[0] << "                   " << sales[0] << "\n";
       cout << name[1] << "                   " << sales[1] << "\n";
	   cout << name[2] << "                   " << sales[2] << "\n";
	   cout << name[3] << "                   " << sales[3] << "\n";
	   cout << name[4] << "                   " << sales[4] << "\n";
	   cout << name[5] << "                   " << sales[5] << "\n";
	   cout << name[6] << "                   " << sales[6] << "\n";
	   cout << name[7] << "                   " << sales[7] << "\n";
	   cout << name[8] << "                   " << sales[8] << "\n";
	   cout << name[9] << "                   " << sales[9] << "\n";
	   cout << name[10] << "                  " << sales[10] << "\n";
	   cout << name[11] << "                  " << sales[11] << "\n";
	   cout << name[12] << "                  " << sales[12] << "\n";
	   cout << name[13] << "                  " << sales[13] << "\n";
	   cout << name[14] << "                  " << sales[14] << "\n";
	   cout << name[15] << "                  " << sales[15] << "\n";
	   cout << name[16] << "                  " << sales[16] << "\n";
	   cout << name[17] << "                  " << sales[17] << "\n";
	   cout << name[18] << "                  " << sales[18] << "\n";
	   cout << name[19] << "                  " << sales[19] << "\n";

	   cout << "\nTotal Sales:" << setw(15) << totalBottlesSold << endl;
       cout << "Top Seller of the Month: "  << name[highSellingProduct] << endl;
       cout << "Low Seller of the Month: "  << name[lowSellingProduct] << endl;

system ("pause");
return 0;
}

    int posOfLargest(int array[], int numBottles)
    {
	int indexOfLargest = 0;

	for (int pos = 1; pos < numBottles; pos++)
	{
		if (array[pos] > array[indexOfLargest])
			indexOfLargest = pos;
	}
	return indexOfLargest;
    }


    int posOfSmallest(int array[], int numBottles)
    {
	int indexOfSmallest = 0;

	for (int pos = 1; pos < numBottles; pos++)
	{
		if (array[pos] < array[indexOfSmallest])
			indexOfSmallest = pos;
	}
	return indexOfSmallest;
    }

Write the getTotal function.
Would that be the same basic structure as the posOfSmallest and Largest functions?
I have it working now. Thanks!
Topic archived. No new replies allowed.