0

I have the following code: my add function and M.add(N) statement keeps turning up errors I'm not sure how to fix it. I also need a getVal function but I'm not sure what to do with it.

```
#include <iostream>
using namespace std;
class sMatrix
{
public:
sMatrix(int,int);
int getR();
int getC();
bool rValid(int);
bool cValid(int);
void setEl(int,int,double);
double getEl(int i,int j);
void print();
void& add();
private:
int nr, nc; //number of row and cols
int nent; //number of entries
int nmax; //the max number of entries
double *data; //store the data, the size of the storage is nmax*3
};
sMatrix::sMatrix(int rr,int cc)
{
nr=rr;
nc=cc;
nent=0;
nmax=(nr*nc)/2;
data=new double [3*nmax];
for (int i=0; i<3*nmax; i++)
data [i]=0.0;
}
int sMatrix::getR()
{
return nr;
}
int sMatrix::getC()
{
return nc;
}
bool sMatrix::rValid(int r)
{
if (r<0 || r>=nr)
return false;
return true;
}
bool sMatrix::cValid(int r)
{
if (r<0 || r>=nc)
return false;
return true;
}
void sMatrix::setEl(int r,int c, double val)
{
int i;
if (rValid(r) && cValid(c))
{
i=3*nent;
data[i]=r;
data[i+1]=c;
data[i+2]=val;
nent++;
}
}
void sMatrix::print()
{
int i;
for (i=0;i<3*nent;i+=3)
{
cout<<"<"<<data[i]<<",";
cout<<""<<data[i+1]<<",";
cout<<""<<data[i+2]<<">"<<endl;
}
}
void sMatrix::add()
{
int i,j;
for (i=0;i<=n;i++)
{
for (j=0;j<=n;j++)
{
m[i,j]+=n[i,j];
}
}
}
void main ()
{
sMatrix M(3,3),N(3,3);
M.setEl(0,0,3);
M.setEl(1,1,4);
M.setEl(2,0,2.4);
M.print();
N.setEl(0,1,0);
N.setEl(1,0,2.3);
N.setEl(0,0,0);
M.add(N);
}
//For the rest of the project it needs:
//getVal function
//sMatrix (M(3,3), N(3,3))
//M.print();
//N.print();
//M.add(N);
//for (i=0;i<=n;i++)
//for (j=0;j<=n;j++)
//m[i,j]+=n(i,j)
//M.sub(N);
```