Hello, mates.
Here is my problem.
I have this array of pointers - **cell.
cells = new Cell*[columns];
for(int i =0 ; i<columns ; i++)
cells[i] = new Cell[rows];
for(int i = 0 ; i < rows ; i++)
for(int j = 0 ; j < columns ; j++)
cells[j][i].setValue(other.cells[j][i].getValueF());
Then i have this destructor :
Table::~Table()
{
for(int i =0 ; i<columns ; i++)
delete[] cells[i];
delete[] cells;
}
But my program doesn't work properly using it. Do you have any idea where my mistake is ? i guess the problem is with the deletion. Thank you in advance !
Unfortunatelly none...
It does compile , and starts running normally.
But when i create an object of Table it fails.
Without the destructor it works properly.
I have a copy constructor including the same code as the destructor, and it does the same thing to the program :( (otherwise i'm sure there is the problem)
Ok. That code looks fine, and is pretty much the same as I use.
That would only fail IF you never created the 2D-array before calling the constructor. So if you tried to delete the memory that you had not allocated.
Try defaulting cells = 0; then in your destructor use