请问各位这个函数重载模板有什么问题,谢谢
#include<iostream>using namespace std;
template<typename E>
E max1(E a,E b)
{a>b?(return a):(return b);}
template<typename E>
E max1(E a)
{return a;}
void main()
{
cout<<max1(1,2)<<max1(5);
}
编译器错误D:\Microsoft Visual Studio\MyProjects\a\b.cpp(5) : error C2059: syntax error : 'return'
D:\Microsoft Visual Studio\MyProjects\a\b.cpp(14) : see reference to function template instantiation 'int __cdecl max1(int,int)' being compiled
执行 cl.exe 时出错.