→ wk7:恩謝謝 妳回答的第一題是我剛剛搞錯了 在妳尚未回文之前有修正 10/14 11:02
→ wk7:我想知道的是這兩種方式使用上意義上的差別在哪?? 10/14 11:03
SpareseMatrix mySparseMatrix,anotherSparseMatrix;
*SpareseMatrix aSparseMatrixPointer;
mySparseMatrix = anotherSparseMatrix;
equal to
mySparseMatrix = mySparseMatrix.operator=(anotherSparseMatrix);
use the prototype :
SparseMatrix& operator=(const SparseMatrix&);
mySparseMatrix = &anotherSparseMatrix;
equal to
mySparseMatrix = mySparseMatrix.operator=(&anotherSparseMatrix);
use the prototype :
SparseMatrix& operator=(const SparseMatrix*);
mySparseMatrix = aSparseMatrixPointer;
equal to
mySparseMatrix = mySparseMatrix.operator=(aSparseMatrixPointer); // 改一下
use the prototype :
SparseMatrix& operator=(const SparseMatrix*);
以上有錯請指正 m(_@_)m
所以 Alien 大說 "沒有另外寫 operator=(SparseMatrix&) 的話"
mySparseMatrix = anotherSparseMatrix; // 不行
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 211.74.9.2
推 adrianshum:開首那個同時寫當然不行, 就這這部份能過, 用的時候也 10/14 12:09
→ adrianshum:會有 ambiguity 10/14 12:09
→ adrianshum:不過你回應不要用 repost 比較好, 我自己都分不出哪些 10/14 12:10
→ adrianshum:是你寫的哪些是我寫的了... 10/14 12:10
→ wk7:紅色那段 equal to 是不是也該用aSparseMatrixPointer呢? 10/14 12:14
※ 編輯: csihcs 來自: 211.74.9.2 (10/14 12:17)
→ csihcs:改好了~~~謝謝兩位大大的提醒 m(_@_)m 10/14 12:17