Hey guys,

So again, I'm trying to create one of the practice programs from my textbook without looking at the book's code. I want to test my skills...

But failure has befallen me and I've given up for tonight. Hopefully one of you can figure this one out.

So far, I have created three arrays: One for product numbers (int), one for the number of units sold (int), and another for sales (double). The directions say to display the list of products in the order of their sales from highest to lowest. The point of the exercise is to practice the selection sort algorithm.

Now, I'm not 100% sure that I did the sort algorithm correctly, so I ask that you don't point out any errors in that function unless you think that it is the cause of my problem:

Even with the dualSort function commented out (as well as the function call, of course), I cannot get the displaySales function to work. I get two linker errors:

Error 1 error LNK2019: unresolved external symbol "void __cdecl displaySales(double * const,int)" (?displaySales@@YAXQANH@Z) referenced in function _main C:\Users\Rob\Rob's Text Files\School Work\Fall 2011\Programming\Labs\Practice\Practice.obj

and

Error 2 error LNK1120: 1 unresolved externals C:\Users\Rob\Rob's Text Files\School Work\Fall 2011\Programming\Labs\Practice\Debug\Practice.exe 1

I've tried a whole bunch of things but I just don't know why I can't call this simple function. Perhaps I just need some sleep, but if anybody could give me a hand, I would very much appreciate it.

There is just one other question that I have: Why do I need to use the NUM_PROD constant as an argument in my function calls? I thought that the whole point of a global variable/constant was that you could reference it in any function. :SCode:`//When sorting the Units Sold, also sort the Product Number, using the same index number.`

//Remember to properly swap the places of values in BOTH arrays.

#include <iostream>

using namespace std;

//Function prototypes

void dualSort(int [], double [], int); //highest to lowest

int totalUnits(int[], int); //calc total units

double totalSales(int[], int); //calc total sales

void displaySales(double[], int); //TEMPORARY for testing sort function!!!

//Global constant

int const NUM_PROD = 9;

int main()

{

int prodNum[NUM_PROD] = {914,915,916,917, //Product Numbers

918,919, 920, 921,922};

int units[NUM_PROD] = {842,416,127,514, //Number of units sold per month

437,269,97,492,212};

double sales[NUM_PROD] = {12.95,14.95,18.95, //total sales per month

16.95,21.95,31.95,

14.95,14.95,16.95};

cout << "Displaying non-sorted sales:" << endl;

//call display sales

displaySales(sales, NUM_PROD);

//call sort function

dualSort(prodNum, sales, NUM_PROD);

cout << "Displaying sorted sales from HIGHEST to LOWEST:" << endl;

displaySales(sales, NUM_PROD);

return 0;

}

//dualSort function

void dualSort(int num[],double sales[],int size)

{

//Hold the max values of sales

double maxSale;

int maxSaleIndex, startScan;

for (startScan = 0; startScan < (size - 1); startScan++)

{

maxSaleIndex = startScan;

for (int index = (startScan + 1); index < size; index++)

{

if (sales[index] > sales[maxSaleIndex])

{

maxSale = sales[index];

maxSaleIndex = index;

}

}

sales[maxSaleIndex] = sales[startScan];

sales[startScan] = maxSale;

}

}

void displaySales(double sales[], double size)

{

for (int i = 0; i<size; i++)

cout << sales[i] << " " << endl;

}