【发布时间】:2015-04-02 05:23:02
【问题描述】:
我希望能够返回两个值中的较大者,无论是整数、双精度还是类。我已经为要使用的类重载了比较运算符。该函数主要给我链接器错误。代码如下:
template <typename tType>
void returnGreater(tType &A, tType &B)
{
if(A > B)
{
cout << "A is greater"; //testing
return A;
}
else
{
cout << "B is greater"; //testing
return B;
}
}
【问题讨论】:
标签: c++ function templates overloading