[問題] compile 過不了???
( *[1m *[m 為色碼,可以按 Ctrl+V 預覽會顯示的顏色 )
( 未必需要依照此格式,文章條理清楚即可 )
開發平台: Dev-C++
補充說明:
class Matrix
{
public:
int nRow;
int nCol;
Complex **z;
Matrix();
Matrix(int x, int y);
~Matrix();
Matrix operator+(Matrix &m);
void operator=(Matrix &m);
};
Matrix Matrix::operator+(Matrix &m)
{
cout << "+" << endl;
Matrix y(this->nRow, this->nCol);
int i, j;
for(i=1; i<=this->nRow; i++)
for(j=1; j<=this->nCol; j++)
y.z[i][j] = this->z[i][j]+m.z[i][j];
return y;
}
void Matrix::operator=(Matrix &m)
{
cout << "=" << endl;
this->nRow = m.nRow;
this->nCol = m.nCol;
int i, j;
for(i=1; i<=this->nRow; i++)
for(j=1; j<=this->nCol; j++)
this->z[i][j] = m.z[i][j];
//return *this;
}
int main(int argc, char *argv[])
{
while(true)
{
Matrix x(3, 3);
Matrix y(3, 3);
Matrix z(3, 3);
z = x+y;
}
system("PAUSE");
return EXIT_SUCCESS;
}
編譯器在這行 y = x+y;
出現
no match for 'operator=' in 'z = Matrix::operator+(Matrix&)(((Matrix&)(&y)))'
但是單純打 x+y 或 y = x
都可以過 實在不知道為什麼
麻煩請大家指點一下
如果需要其他程式碼我在po上
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.231.212
→
08/04 23:38, , 1F
08/04 23:38, 1F
→
08/04 23:43, , 2F
08/04 23:43, 2F
→
08/04 23:43, , 3F
08/04 23:43, 3F
→
08/04 23:45, , 4F
08/04 23:45, 4F
→
08/04 23:48, , 5F
08/04 23:48, 5F
→
08/04 23:48, , 6F
08/04 23:48, 6F
→
08/04 23:48, , 7F
08/04 23:48, 7F
→
08/04 23:49, , 8F
08/04 23:49, 8F
→
08/04 23:51, , 9F
08/04 23:51, 9F
推
08/05 01:29, , 10F
08/05 01:29, 10F