#ifndef QUICK_SORT #define QUICK_SORT template <class T> inline void swap(T& t1,T& t2) { T t; t = t1; t1 = t2; t2 = t; } 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[i],array[j]); }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 出现的错误: error C2668: “swap” : 对重载函数的调用不明确 原因是与STL中swap重复。