I have this piece of code and for some reason it creates 6 memory leaks and I can't figure out where.
Lemon::Lemon()
{
this->nrOf=0;
int x=10;
this->matrix=new int*[x];
this->lines=new string[x];
for (int i = 0; i < x; ++i)
this->matrix[i] = new int[x];
for(int i=0;i<x;++i)
for(int j=0;j<x;++j)
this->matrix[i][j]=-1;
}
Lemon::Lemon(int n)
{
this->x=this->nrOf;
this->matrix=new int*[x];
this->lines=new string[x];
for (int i = 0; i < x; ++i)
this->matrix[i] = new int[x];
for(int i=0;i<x;++i)
for(int j=0;j<x;++j)
this->matrix[i][j]=-1;
}
Lemon::~Lemon()
{
for(int i=0;i<this->nrOf;i++)
{
delete []this->matrix[i];
}
delete []this->matrix;
delete []this->lines;
}
Any kind of help is appreciated.