[問題] C++ 矩陣輸入值在做完+法*法後被改了
寫了個矩陣相加相乘的class
假設輸入a,b兩矩陣
在做完a+b或a*b時
a的值就被改掉
cout<<a;
answer=(a+b);
cout<<a;
前後出來的a不同
接著去看operator+
在return前 cout<<*this; 出來看
cout<<*this;
return answer;
this沒被變動
後來又去看了operator=
SparseMatrix& SparseMatrix::operator=(const SparseMatrix& rhs)
在return之前把*this跟rhs cout出來看
cout<<*this<<endl<<rhs;
return *this;
都沒有錯
那a到底在哪裡被改到??
懇請板上的大大為小弟解惑
感謝
--
※ Origin: 交大次世代(bs2.to)
◆ From: sky.Dorm13.NCTU.edu.tw
討論串 (同標題文章)
以下文章回應了本文 (最舊先):
完整討論串 (本文為第 1 之 3 篇):