フレームクラスに次のようなデストラクタがあります。
delete this->frameMatrix;
framematrixがクラスMatrixであり、これがコンストラクタおよびデストラクタとして使用されている場合:
// Constructor: Initialize matrix & sizes
Matrix::Matrix(int width, int height)
{
table = new double* [height];
for(int i = 0; i < height; i++)
table[i] = new double [width];
// Set all values to zero
for(int row = 0; row < height; row++)
{
for(int col = 0; col < width; col++)
{
table[row][col] = 0;
}
}
this->width = width;
this->height = height;
}
// Destructor: delete matrix
Matrix::~Matrix()
{
for(int row = 0; row < height; row++)
delete [] table[row];
delete [] table;
this->width = 0;
this->height = 0;
}
frameMatrixでdeleteを呼び出すと、プログラムはmatrixのデストラクタで失敗したアサーションを返します。
2d double配列を削除する方法に問題がないため、何か間違ったことをしています。
編集:
コピーコンストラクター:
Matrix::Matrix(const Matrix &m)
{
this->height = m.getHeight();
this->width = m.getWidth();
this->table = new double* [height];
for(int i = 0; i < height; i++)
this->table[i] = new double [width];
for(int row = 0; row < height; row++)
{
for(int col = 0; col < width; col++)
{
this->table[row][col] = m.table[row][col];
}
}
}
私のオーバーロード=
Matrix &operator = (const Matrix &m)
{
this->height = m.getHeight();
this->width = m.getWidth();
this->table = new double* [height];
for(int i = 0; i < height; i++)
this->table[i] = new double [width];
for(int row = 0; row < height; row++)
{
for(int col = 0; col < width; col++)
{
this->table[row][col] = m.table[row][col];
}
}
}