討論串[問題] template+operator overloading的問題
共 2 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓1(1推 0噓 2→)留言3則,0人參與, 最新作者Tonix517 (大屁孩~)時間16年前 (2009/03/19 23:06), 編輯資訊
0
0
0
內容預覽:
test<float> 和 test<A>實際上是兩個不同的類(實際上你可以把template看做帶型態的宏)。而temp1+temp2調用的是 test<float>::operator+(test<float>&) - 如你的模板定義。. 如果要實現temp1+temp2,你必須要特化templ

推噓1(1推 0噓 2→)留言3則,0人參與, 最新作者x3795566 (冀憶)時間16年前 (2009/03/19 22:55), 編輯資訊
0
0
0
內容預覽:
假設我有一個結構為A 一個class為test. 然後在main中 我宣告了兩個物件temp1,temp2. test<float> temp1;. test<A> temp2;. 然後我欲使temp1+temp2 所以打算多載運算子. 而有下面程式碼(只貼定義部份). template <clas
(還有210個字)
首頁
上一頁
1
下一頁
尾頁