Parallel arrays problem-unresolved externals

Hi there, my homework assignment was to create a program that kept track of a companies salsa sales. The requirements were to use two parallel five element arrays holding salsa names and the number of salsa jars sold. I believe I have almost done everything correctly however when I try and run my program there are unresolved externals, my least favorite error as of now. I am not really sure what the deal is and all my functions have a body so I dont know what it could be. Anyways, if anyone has any ideas on what my issue might be I would love to hear it, thanks!

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
 #include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int GetSalesData (string [], int []);
int PositionOfLargest (int []);
int PositionOfSmallest (int []);
void DisplayReport (string[], int[], int);

const int Size = 5;

int main()
{
	
	string Name[Size] = {"mild", "medium", "sweet","hot" , "zesty"};
	int Sales[Size];

	int TotalJarsSold = GetSalesData(Name, Sales);

	DisplayReport(Name ,Sales ,TotalJarsSold);

	return 0;
}

int GetSalesData(string Name[], int Sales[])
{
	int Total = 0;

	for (int Type = 0; Type < Size; Type++)
	{

		cout << "Jard sold last month of " << Name[Type] << ": ";
		cin >> Sales[Type];

		while (Sales[Type] <0)
		{
			cout << "Jars sold must be 0 or more. Please re-enter: ";
			cin >> Sales[Type];
		}
		Total += Sales[Type];
	}
	return Total;
}

void DisplayReport (string Name[], int Sales[], int Total[])
{

	int HighSalesProduct = PositionOfLargest(Sales);
	int LowSalesProduct = PositionOfSmallest(Sales);

	cout << "\n\n Salsa Sales Report \n\n";
	cout << "Name       Jars Sold \n";
	cout << "______________________\n";

	for (int Type = 0; Type < Size; Type++)
		cout << Name[Type] << setw(11) << Sales[Type] << endl;


	cout << "\nTotal Sales:" << Total << endl;
	cout << "\nHigh Seller:" << Name[HighSalesProduct] << endl;
	cout << "\nLow Seller:" << Name[LowSalesProduct] << endl;


}

int PositionOfLargest(int array[])
{
	int IndexOfLargest = 0;

	for (int Pos = 1; Pos < Size; Pos++)
	{
       if (array[Pos] > array[IndexOfLargest])
		   IndexOfLargest = Pos;

	}
	return IndexOfLargest;
}

int PositionOfSmallest(int array[])
{
	int IndexOfSmallest = 0;

	for (int Pos = 1; Pos < Size; Pos++)
	{
       if (array[Pos] < array[IndexOfSmallest])
		   IndexOfSmallest = Pos;

	}
	return IndexOfSmallest;
}
Look carefully on line 46 on your function parameters, and then compare it with the prototype. (Hint: which ones are suppose to be arrays, which ones are not suppose to be?)
Do your function prototypes, function implementations, and function calls all agree as to the number and types of parameters. They must all agree or you will get this type of error. Your error messages should tell you which function is calling the problems. And remember a single instance of a type is not the same as an array of that type.

Also it is usually a good idea to make the prototype look exactly like the function implementation. For example


1
2
3
4
5
//void DisplayReport (string[], int[], int);  // Poor practice.
void DisplayReport (string Name[], int Sales[], int Total); // Better since it should be identical to the function implementation.
void DisplayReport (string Name[], int Sales[], int Total[])  // Do you see any differences? 
{
   ...



Last edited on
Wow I see it now, Yeah I cant believe I didint catch that one. Thanks!
Kevin,
Topic archived. No new replies allowed.