- #ifndef MATRIX_H_INCLUDED
-
#define MATRIX_H_INCLUDED
-
#include <string>
-
class Matrix{
-
public:
-
size_t rows;
-
size_t cols;
-
size_t **matrix;
-
Matrix();
-
Matrix(size_t rows, size_t cols);
-
~Matrix();
-
};
-
-
-
#endif // MATRIX_H_INCLUDED
#include "Matrix.h"
Matrix::Matrix(){
this->matrix = 0;
}
Matrix::Matrix(size_t rows, size_t cols){
this->rows=rows;
this->cols=cols;
//size_t **q =0;
this->matrix =new size_t*[rows];
for(size_t i=0; i
//*((q)+i) = new size_t[cols];
*(this->matrix+i) = new size_t[cols];
}
for(size_t i=0; i for(size_t j=0; j this->matrix[i][j]=0;
}
}
size_t a;
}
Matrix::~Matrix(){
for(size_t i=0; irows; i++){
delete[] *(this->matrix+i);
}
delete[] this->matrix;
}
////*(this->matrix+i)=this->matrix[i]
//this->matrix + i是指向this->matrix[i]的地址的地址必须用*(this->matrix+i)来取得