C++模板实参的省略

2025-05-12 19:29:32
推荐回答(1个)
回答(1):

第一种情况:template void fun(T const& a,T const& b);但是你调用时却是fun(250,250.4);那你就必须写成fun(250,250.4);
第二种情况:template RT fun(T const& a,T const& b);此时没有办法进行演绎,所以你可以重写template RT fun(T const& a,T const& b);调用时写成fun(12,13);

第四种就是template void fun();调用时直接是fun()!!