Basically i have made a binary class that inherits from a matrix class. and aparantly when i make the binary image the deconstructor doesn't work properly. the program runs, reads in the files and makes the binary matrix. However when the binary deconstructor and matrix deconstructors are called, the program fails and shoot to this line of code./* verify block type */_ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse));
I don't know what this means even after looking online, I'm going to guess the pointer isn't being deleted, so maybe somebody could help me.
This is the matrix class
class Matrix
{
private:
//double* data;
int value;
public:
double* data;
int M;
int N;
Matrix();
Matrix(int MM, int NN);
//Matrix(const Matrix&);
Matrix(const Matrix& rhs); //deep copy
Matrix(int MM, int NN, double* input_data);
virtual ~Matrix();
double getRead(int i, int j) const;
double getReadWrite(int i, int j);
void set(int i, int j, double val);
void Print();
Matrix* sum1(Matrix* rhs);
double* to1DArray();
///operators
virtual Matrix* operator +(Matrix* rhs) const;
virtual Matrix* operator -(Matrix* rhs) const;
virtual Matrix* operator *(Matrix* rhs) const;
virtual Matrix* operator /(Matrix* rhs) const;
virtual Matrix& operator =(Matrix* rhs);
///overload double operators
Matrix* operator +(double* rhs) const;
Matrix* operator -(double* rhs) const;
Matrix* operator *(double* rhs) const;
Matrix* operator /(double* rhs) const;
Matrix* operator =(double* rhs);
///min,max,sum,mean
double min(Matrix* rhs) const;
double max(Matrix* rhs) const;
double sum() const;
double mean() const;
//double SqaureRoot() const;
};
and this is the binary class which inherits from the matrix class
class BinaryImage: public Matrix
{
private:
char ThreshData(double thresh);
public:
double* input_data;
BinaryImage();
BinaryImage(int MM, int NN, double* input_data){ThreshData(0);};
//BinaryImage(int MM, int NN){ThreshData(1);};
~BinaryImage();
Matrix* operator +(Matrix* rhs) const;
Matrix* operator -(Matrix* rhs) const;
Matrix* operator *(Matrix* rhs) const;
Matrix* operator /(Matrix* rhs) const;
Matrix* operator +(double* rhs) const;
Matrix* operator -(double* rhs) const;
Matrix* operator *(double* rhs) const;
Matrix* operator /(double* rhs) const;
};
BinaryImage::BinaryImage()
{
cout << "BinaryImage Constructor...\n";
}
This next bit of code is what calls the class
void function()
{
double* data = 0;
double* shufData = 0;
int M=0; int N=0;
cout << endl;
cout << "Data from text file -------------------------------------------" << endl;
M = 512; N = 512; //M and N represent the size of the image, e.g. for task 1, M = 512, N = 512
char* fileName2 = "...\\logo_bi.txt";
data = readTXT(fileName2, M, N);
cout << endl;
cout << "Data from text file -------------------------------------------" << endl;
M = 512; N = 512; //M and N represent the size of the image, e.g. for task 1, M = 512, N = 512
char* fileName3 = "...\\logo_shuf.txt";
shufData = readTXT(fileName3, M, N);
cout << "---------originalImage----------"<< endl;
BinaryImage originalImage(32,32, data);
}
It was after this is called that it dies.
Thank you in advanced