注册 登录
编程论坛 C++教室

我是C++初学者,函数模板有点不懂

sunshine萝卜 发布于 2016-04-17 22:17, 3706 次点击
在VS2012环境下编写的程序

#include <iostream>
using namespace std;

template<classT>
T GetMax(T a,T b)
{
    T c;
    if(a>b)
        c=a;
    else
        c=b;
    return c;
}
void main()
{
    int m=6,n=3,k;
    k=GetMax<int>(m,n);//这里显示错了
    cout<<k<<endl;
    system("pause");
}
我该怎么调用函数模板呢?
1 回复
#2
c9742884322016-04-18 11:41
template<classT>   class T  你的有空格么
1