hi :
while compiling ,i confronted a problem in template.
here is the code ,very short.
The codes can be compiled through,however there are warnings .
i was confused by these warnings.
Code:
#include<iostream>
using namespace std;
template <class T>
T &max(T x[],int n)
{int i;
T maxv=x[0];
for(i=1;i<n;i++)
if(maxv<x[i])
maxv=x[i];
return maxv;
}
int main()
{
int a[]={4,5,2,8,9,3};
double b[]={3.5,6.7,5.2,9.2};
cout<<"max of a is:"<<max(a,6)<<endl;
cout<<"max of b is:"<<max(b,4)<<endl;
return 0;
}