在下面的代碼爲什麼,如果我的休閒區const
盈的Data
我得到的錯誤error C2662: 'double Data::getValue(const int,const int)' : cannot convert 'this' pointer from 'const Data' to 'Data &'
爲什麼const不能用於對象參數的前面?
bool Data::equal(Data &aabb)
{
for (int i = 0; i < MAX_ROWS; i++){
for (int j = 0; j < MAX_COLUMNS; j++){
if (aabb.getValue(i, j) != m[i][j])
return false;
}
}
return true;
}
您已經定義了'getvalue'方法,它要求對象是可變的。 – user2357112