I am getting a segmentation fault when I try to call a class function in my program. During my program, the matrix grid[][] changes rapidly, and I want to be able to at a certain time save an “image” of the grid, so that I can compare later versions of the grid to this reference. So when I try to save the “image” of grid[][] to the reference matrix, I simply copy all of the values to it using a for loop. I did a couple tests during my program and I seem to be getting a segmentation fault during the getreference function.
class lattice
{
public:
lattice(){} // Constructor
~lattice(){} // Destructor
void getgrid(){...}
//Other functions...
void getreference()
{
for(int a = 0; a<SIZEX; a++)
{
for(int b = 0; a<SIZEY; b++)
{
reference[a][b] = grid[a][b];
}
}
}
private:
short grid[SIZEX][SIZEY];
short reference[SIZEX][SIZEY];
}
should be
That’s why you got a segmentation fault.