everyone:
Im creating a program that is able to create Matrices and and perform various operations on them for a course at school. They require us to overload the operators with with the appropriate Matrix Operations.
I am having a hard time with the following function:
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 warns me that at the following line:
if (B[row][col] != a[row][col])
type 'const Matrix' doesn't provide a subscript operator
Note: Function Headers,constructors and other functions have been omitted from this code portion.
Any help would be greatly appreciated. Thank you.