Matrixを作成し、学校のコースでさまざまな操作を実行できるプログラムを作成しています。彼らは適切なマトリックス操作でオペレータを過負荷にする必要があります。
私は次の関数で苦労しています:
typedef double matrixType;
using namespace std;
class Matrix{
protected:
int m,n; // m:row size n:column size
matrixType **a; //Allows us to acces the a(ij) i,j position of the matrix
//==================================================
// (==Operator)Verifies if two given Matrices are equal
//==================================================
bool Matrix::operator==(const Matrix &B){
bool flag=false;
if(B.m ==m && B.n ==n){
for (int row=0; row<m; row++) {
for (int col=0; col<n; col++) {
if (B[row][col] != a[row][col]) {
flag=false;
}
}
}
flag= true;
}
else{
flag=false;
}
return flag;
}
Xcodeのは、次の行であることを私に警告します:
if (B[row][col] != a[row][col])
型「constのマトリックス」添字演算子を提供していません。
注:このコード部分では、機能ヘッダー、コンストラクターおよびその他の機能が省略されています。
ご協力いただければ幸いです。 ありがとうございます。あなたの実装を考えると
おそらく_also_添字演算子を与える必要があります。 –
ヘルプとリソースをありがとう、ありがとう、それを読んでください。 – edu222