the code below has this error.
main.obj : error LNK2001: unresolved external symbol "void __cdecl BubbleSort(int * const,int)" (?BubbleSort@@YAXQAHH@Z)
Debug/Bubblesort2.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
What have I done wrong? Please help!
Code:
#include<iostream>
using namespace std;
void Swap(int& num1, int& num2);
void DisplayArray(int array[], int arraySize);
void BubbleSort(int array[], int arraySize);
int main(void)
{
int ages[]={3,5,4,7};
DisplayArray(ages, (sizeof ages/sizeof ages[0]));
BubbleSort(ages, (sizeof ages/sizeof ages[0]));
DisplayArray(ages, (sizeof ages/sizeof ages[0]));
return(0);
}
void DisplayArray(int array[], int arraySize)
{
for(int i=0; i<arraySize; i++)
{
cout << array[i];
if(i!=arraySize-1)
{
cout << ',';
}
}
cout << endl;
}
void Bubblesort( int array[], int n )
{
for ( int i = 0; i < n-1; ++i )
for ( int j = 1; j < n-i; ++j )
if ( array[j-1] > array[j] )
// Note the use here of swap()
swap( array[j-1], array[j] );
}
void Swap(int &x, int &y)
{
int z = x;
x = y;
y = z;
}