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

推噓3(3推 0噓 8→)留言11則,0人參與, 最新作者QQ29 (我愛阿蓉)時間16年前 (2009/10/20 10:59), 編輯資訊
0
0
0
內容預覽:
請問l大說的copy assignment是發生在return 這個時候嘛?. 那為啥不是呼叫copy constructor而是呼叫opt =??. 還有請教RVO 全名是return value object嘛? google打查不太到.... --. 發信站: 批踢踢實業坊(ptt.cc)

推噓3(3推 0噓 13→)留言16則,0人參與, 最新作者littleshan (我要加入劍道社!)時間16年前 (2009/10/20 10:25), 編輯資訊
0
0
0
內容預覽:
當你這樣寫的時候. [修正]. - 實際上是呼叫一次 copy-assignment (oTest.GetList). - 以及一次 copy-constructor. - 不過前面那個 copy-assignment 被 RVO 消掉了. - 所以沒呼叫到 List::operator=. [/修
(還有352個字)

推噓2(2推 0噓 5→)留言7則,0人參與, 最新作者ACMTino (哈哈哈)時間16年前 (2009/10/20 01:55), 編輯資訊
0
0
0
內容預覽:
List Test::GetList(). {. return m_oList;. }. Test oTest;. List oList = oTest.GetList();. 這樣子做還是會取得 m_oList, 等於 oList 是 m_oList 的別名. 那修改 oList 就會改到 m_o
(還有1390個字)

推噓1(1推 0噓 5→)留言6則,0人參與, 最新作者csihcs (非天夜翔)時間16年前 (2009/10/14 11:35), 編輯資訊
0
0
0
內容預覽:
怎麼覺得兩個同時寫在 class 中,會 compile 不過。. 想法參考自:. class A {. A method(const A&) {return *this;}. A& method(const A&) {return *this;}. };. 這樣寫 compiler 會回應有錯吧。
(還有757個字)

推噓1(1推 0噓 2→)留言3則,0人參與, 最新作者adrianshum (Alien)時間16年前 (2009/10/14 10:49), 編輯資訊
0
0
0
內容預覽:
大概是你搞錯了, 應該不會 return this. 你這兩個 overload 要 return 的都是 SparseMatrix,. 除非你碰巧有一個 ctor 是 SparseMatrix(SparseMatrix*). 我記得好像 compiler 會自動幫你用這 ctor (不肯定). 可
(還有130個字)
首頁
上一頁
1
2
下一頁
尾頁