代码如下:
#include
using namespace std;
template
T Add(T a, T b)
{
return a + b;
}
int main()
{
cout << Add(3, 4) << endl;
cout << Add(3.4, 4.4) << endl;
system("pause");
return 0;
}
在使用函数是必须要有
#include...〈stdio.h〉
#include〈math.h〉
{
然后是函数名();
}
这是手机大的可能格式有点问题,不过就是这种形式。