please some one should help me, i have code for addition, subtraction, and multiplication, but i don't know how to code for transpose and inverse.
#include <iostream>
using namespace std;
//member function of matrix class
class matrix{
public:
matrix();
matrix(int m,int n);
int getRow();
int getCol();
double& operator()(int, int);
//the operator used in the matrix class which are (addition operator, multiplication operator,substraction operator, and
friend ostream& operator<<(ostream& os, matrix& m);
matrix operator + (matrix&);
matrix operator * (matrix&);
matrix operator - (matrix&);
private:
void init(int, int);
int nrows,ncols;
double *data;
};
matrix::matrix(){
init(1,1);
}
matrix::matrix(int m, int n){
init(m,n);
}
//destructor to delete the used dynamic memory.
void matrix::init(int m, int n){
nrows=m;
ncols=n;
data= new double[m*n];
for(int i=0; i<m*n; i++)
data[i]=0;
}
int matrix::getRow() { return nrows;}
int matrix::getCol() { return ncols;}
double& matrix::operator ()(int r, int c){
if (r <0 || r> nrows){
cout<<"Illegal row index";
return data[0];
}
else if (c <0 || c > ncols){
cout<<"Illegal Column Index:";
return data[0];
}
else return data[r*ncols+c];
}