模版问题 怎么编译不过去了?
template<class Type,int size>Type min(Type (&r_array)[size])
{
Type min_val=r_array[0];
for(i=1;i<size;++i)
if(min_val>r_array[i])
min_val=r_array[i];
return min_val;
}
int ia[]={1,5,7,9,0};
double da[]={1.2,2.5,6.1,9.8,10.6};
#include<iostream>
using namespace std;
int main()
{
int i=min(ia);
if(i!=0)
cout<<"错误"<<endl;
else cout<<"正确"<<endl;
double d=min(da);
if(d!=1.2)
cout<<"错误"<<endl;
else cout<<"正确"<<endl;
return 0;
}