c++ - Segmentation Fault declaring class private variable -
i getting segmentation fault when seek phone call class function in program. during program, matrix grid[][]
changes rapidly, , want able @ time save "image" of grid, can compare later versions of grid reference. when seek save "image" of grid[][]
reference matrix, re-create of values using loop. did couple tests during programme , seem getting segmentation fault during getreference
function.
class lattice { public: lattice(){} // constructor ~lattice(){} // destructor void getgrid(){...} //other functions... void getreference() { for(int = 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]; }
for(int b = 0; < sizey; b++)
should
for(int b = 0; b < sizey; b++)
that's why got segmentation fault.
c++ class segmentation-fault
No comments:
Post a Comment