函数模板头文件编译错误。
问题:
LINK : error LNK2001: 无法解析的外部符号 _mainCRTStartup
1>C:\Users\Administrator\Documents\Visual Studio 2010\Projects\12.3\Debug\12.3.exe : fatal error LNK1120: 1 个无法解析的外部命令
代码:
#ifndef QUIKSORT_H
#define QUIKSORT_H
template<class T>
inline void swap(T& t1,T& t2)
{
T hold = t2;
t2 = t1;
t1 = hold;
}
template<class T>
void quicksort(T *array,int hi,int lo= 0)
{
while (hi >lo) {
int i =lo;
int j =hi;
do {
while (array[i] < array[lo] && i<j)
i++;
while(array[--j] >array[lo]);
if(i<j)
swap(array[j] array[i]);
}
while (i<j);
swap(array[lo],array[j]);
if(j-lo>hi - (j+1)){
quicksort(array,j-1,lo);
lo= j+1;
}
else {
quicksort(array,hi,j+1);
hi=j-1;
}
}
}
#endif
代码图片: