[問題] class呼叫成員函式
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
c++
問題(Question):
我有一個class Complex (就是複數, 有real跟imag在private裡)
其中有兩個member func
void showXY()const{...cout << real << "+" << imag << "i";...}
void conj()const{
this->b=b*-1 //共厄複數
}
然後宣告 const Complex test( 1 , 0.5 )
並呼叫test.conj().showXY();
預期的正確結果(Expected Output):
1-0.5i
錯誤結果(Wrong Output):
compile不會過 會說invalid use of void
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.241.250
推
12/21 20:24, , 1F
12/21 20:24, 1F
→
12/21 20:31, , 2F
12/21 20:31, 2F
→
12/21 20:32, , 3F
12/21 20:32, 3F
→
12/21 21:11, , 4F
12/21 21:11, 4F
→
12/21 21:11, , 5F
12/21 21:11, 5F
→
12/21 21:13, , 6F
12/21 21:13, 6F
討論串 (同標題文章)