I have to create a function template that will sort an int, float, or string filled array in ascending order. The function will receive an unordered array, and it will return an ordered array. Right now i am just trying to get the function to sort the int array. I am trying to use the qsort function, but i am having trouble. It comes up with the following error:
'compare': local function definitions are illegal.
my code:
Code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

template<typename Type>
void Sort_Array(Type *Array1, int Num_Elem)
{
	Num_Elem = Num_Elem - 2;
	while(Num_Elem >= 0)
	{
		cout<<Array1[Num_Elem]<<" ";       //tests that the array was filled corectly
		Num_Elem--;
	}

	int compare (const void * a, const void * b)
	{
	 return ( *(int*)a - *(int*)b );                                
	}

	qsort (Array1, 24, sizeof(int), compare);

}
int main()
{
	ifstream Filein;
	Filein.open("G:\\IntFile.dat");
	int count = 0;
	int Array1[100];

	while(Filein)
	{
		Filein>>Array1[count];
		count++;
	}
	Sort_Array(Array1, count);

return 0;
}
I used a loop to make sure the array was filled correctly, and it was. I was trying to follow an example online, but i can't get it to work.