Hi,
I'm a new member who is fairly new to C++ and need a little help getting some bugs out of an assigned matrix project.
I am running VC++ 6.0 and have no compiler errors. Also, I have managed to run the program successfully for small matrices. My probelm occurs for large uneven matrices where I end up getting a segmentation fault. Using my debugger I isolated the most likely cause to my third constructor shown here:
Matrix::Matrix(int row, int col, string data)
{
m_Rows = row;
m_Cols = col;
int i=0, j=0;
mat_Data = new int *[m_Rows];
for(int q=0; q<m_Rows; ++q)
mat_Data[q] = new int [m_Cols];
for(int k=0; k<data.size(); ++k){
if(data[k] == '1'){
mat_Data[i][j] = 1; //trouble with this assignment
++j;
if(j >= m_Rows){
j=0;
++i;
}
}
else if(data[k] == '0'){
mat_Data[i][j] = 0;
++j;
if(j >= m_Rows){
j=0;
++i;
}
}
else if(isspace(data[k])|| data[k] == ',')
continue;
else
throw MatrixError();
}
}
Note that this project is restricted to entries of matrices- integer modulo 2.
I am not sure why the compiler is dumping the the program for only certain types of matrices.
I would appreciated any help I could get from one of you C++ experts.
Thanks