C++模板简单问题
#include<iostream.h>
//using namespace std;
template <typename T>;
T abs<T x>;
{
return x<0? -x:x;
}
int main()
{
int n=-5;
double d=-5.5;
cout<<abs(n)<<endl;
cout<<abs(d)<<endl;
}
怎么错了?
--------------------Configuration: 函数模板 - Win32 Debug--------------------
Compiling...
P285.CPP
D:\c++\pvc6\MyProjects\函数模板\P285.CPP(3) : error C2059: syntax error : '<end Parse>'
D:\c++\pvc6\MyProjects\函数模板\P285.CPP(5) : error C2447: missing function header (old-style formal list?)
D:\c++\pvc6\MyProjects\函数模板\P285.CPP(12) : error C2065: 'abs' : undeclared identifier
D:\c++\pvc6\MyProjects\函数模板\P285.CPP(14) : warning C4508: 'main' : function should return a value; 'void' return type assumed
Error executing cl.exe.
P285.OBJ - 3 error(s), 1 warning(s)