0
爲什麼我收到一個錯誤說:函數模板超載問題
- 錯誤C2668:「最大」:不明確調用重載函數
- 錯誤C2780:「常量牛逼&最大(常量牛逼&,常量T &,const T &)':期望3個參數 - 2提供。
下面的代碼:
template<typename T>
inline T const& max(T const& i, T const& j)
{
cout<<"Using template with 2 args."<<endl;
return (i>j) ? i : j;
}
template<typename T>
inline T const& max(T const& i, T const& j, T const& k)
{
cout<<"Using template with 3 args."<<endl;
return max(max(i,j),k);
}
void main()
{
cout<< ::max(1,2,3)<<endl;
}
我已經調用它之前定義的參數2模板函數。
感謝您的回答。那太傻了。 – Anitesh