Click on the edit button in the bottom right hand corner of the post and correct it. :)Quote:
Sorry about the last comment. I forgot to close to code tag
Printable View
Click on the edit button in the bottom right hand corner of the post and correct it. :)Quote:
Sorry about the last comment. I forgot to close to code tag
I FINALLY GOT IT!!! Turns out the problem was with the general constructor: I forgot to assign values for the individual data members (row, col, and empty). For some reason, after assigning the proper values, everything worked fine. In case you're curious, here is what I changed in the code (and good riddance to this problem once and for all):
By the way, thanks to all of you for helping me out. It was really helpful.Code:Matrix::Matrix(const Matrix &another)
{
row = another.row;
col = another.col;
if(!another.empty)
{
empty = false;
A = new Complex* [another.row];
for (int i=0; i<row; i++)
A[i] = new Complex[another.col];
for (i=0; i<row; i++)
{
for (int j=0; j<col; j++)
{
A[i][j] = another(i,j);
}
}
}
else
empty = true;
}
Matrix::Matrix(const int &a, const int &b)
{
row = a;
col = b;
if(a==0 && b==0)
{
empty = true;
}
else
{
empty = false;
A = new Complex* [row];
for (int i=0; i<row; i++)
A[i] = new Complex[col];
for (i=0; i<row; i++)
{
for(int j=0; j<col; j++)
{
A[i][j] = 0; //zero-out the entire matrix;
}
}
}
}