怎样写普通的流插入重载函数?
#include <iostream>
using std::cout;
using std::endl;
template <class T>
void operator < <(ostream &output,T a[])
{
for(int i=0;i <10;i++)
output < <a[i] < <' ';
}
template <class T>
void InsertionSort(T a[],int n)
{
int i,j;
T temp;
for(i=1;i <n;i++)
{
j=i;
temp=a[i];
while(j>0&&temp <a[j-1])
{
a[j]=a[j-1];
j--;
}
cout < <a;
cout < <endl;
}
}
int main()
{
const int S=10;
int a[S]={1,3,5,2,4,8,9,0,6,7};
InsertionSort(a,S);
return 0;
}
想这样子,怎么写流插入函数?
谢谢