各位请帮我纠正这程序,THANK YOU!!
程序题目如下:
编写一个函数模板,它返回两个值中的最小者,但同时要确保能正确处理字符串.
我编的程序如下:
#include<iostream.h>
#include<string.h>
template<class T>
T Min(T a,T b)
{
if(sizeof(T)<2)
return(strcmp(a,b)<0?a:b);
/*'strcmp' : cannot convert parameter 1 from 'const int' to 'const char *'*/
return a<b?a:b;
}
void main()
{
cout<<"Min(3,5) is"
<<Min(3,5)<<endl;
/*see reference to function template instantiation 'const int __cdecl Min(const int &,const int &)' being compiled*/
cout<<"Min('3','5')is"
<<Min('3','5')<<endl;
}