Hello. Please help me out with the following code...
Code:
class MATRIX
{
private:
float **x;
int m,n;
public:
MATRIX();
MATRIX(int, int);
void getdata();
void showdata();
~MATRIX();
};
MATRIX::MATRIX()
{
m=1; n=1; x=new float*[1]; x[0]=new float[1]; x[0][0]=0;
}
MATRIX::MATRIX(int a, int b)
{
int ctr,row,col;
m=a; n=b;
x=new float*[m];
for(ctr=0; ctr<m; ++ctr)
x[ctr]=new float[n];
for(row=0; row<m; ++row)
{
for(col=0; col<n; ++col)
x[row][col]=0;
}
}
MATRIX::~MATRIX()
{
//what do I type here?
}
I am unable to figure out what code I should use in the destructor to deallocate the memory allocated to the pointer to a pointer x.
Please help out.