我創建了一個簡單的函數,其中包含2個diffrernt模板參數t1,t2和返回類型t3。 到目前爲止沒有編譯錯誤。但是當Itry從main調用該函數時,我遇到錯誤C2783。 我需要知道如果下面的代碼合法嗎?如果不是如何修復? 請幫忙!奇怪的模板錯誤:錯誤C2783:無法推斷模板參數
template <typename t1, typename t2, typename t3>
t3 adder1 (t1 a , t2 b)
{
return int(a + b);
};
int main()
{
int sum = adder1(1,6.0); // error C2783 could not deduce template argument for t3
return 0;
}
'std :: plus'任何人? :) +1 –
2010-05-27 11:32:03
非常感謝您的答覆 – osum 2010-05-30 17:30:37