C++ 模板函数实例化文件?

C++ 模板函数实例化文件?,c++,templates,instantiation,C++,Templates,Instantiation,我以前为类创建过实例化文件,但我很好奇如何为一个函数创建一个。下面是我制作的一个程序示例 template <typename T> void deSelSort(T arr[], int n) { int j = n - 1; for (int i = 0; i < n; i++) { cout << arr[i] << " "; } cout << endl; for(int i = 0; i

我以前为类创建过实例化文件,但我很好奇如何为一个函数创建一个。下面是我制作的一个程序示例

template <typename T>
void deSelSort(T arr[], int n)
{
int j = n - 1;

for (int i = 0; i < n; i++)
    {
        cout << arr[i] << " ";
    }
    cout << endl;

for(int i = 0; i < j; i++, j--) {

    int min=i;
    int max=i;
    int temp;

    for (int temp2 = i + 1; temp2 <= j; temp2++)
    {
        if (arr[temp2] < arr[min]) 
            { 
                min = temp2; 
            }
        if (arr[temp2] > arr[max]) 
            { 
                max = temp2; 
            }
    }

    if (min > max) { 
        temp=min; 
        min=max; 
        max=temp;
        arr[min] = max; 
        arr[max] = min;
    }
    if (min > i) 
    { 
        temp = arr[i]; 
        arr[i] = arr[min];
        arr[min] = temp; 
    }
    if (max < j) 
    { 
        temp = arr[j]; 
        arr[j] = arr[max];
        arr[max] = temp; 
    }

    for (int i = 0; i < n; i++)
    {
        cout << arr[i] << " ";
    }
    cout << endl;


};
}
模板
void deSelSort(T arr[],int n)
{
int j=n-1;
对于(int i=0;iints
double
的数组,那么实例化文件会是什么样子

模板void deSelSort(int[],int);
模板void deSelSort(双精度[],整数);
模板无效deSelSort(int[],int);
模板无效deSelSort(double[],int);
#include "ex3_16.cpp"

template class deSelSort<int>;
template class deSelSort<double>;
template void deSelSort<int>(int[], int);
template void deSelSort<double>(double[], int);