I do have to following code:
bool SudokuField::blockContainsByBlock(const short &block_x, const short &block_y, const short &value)
{
assertRange(block_x, 0, 2);
assertRange(block_y, 0, 2);
return this->blockContains(block_x * 3, block_y * 3, value);
}
bool SudokuField::blockContains(const short &x, const short &y, const short &value)
{
assertRange(value, 1, 9);
assertRange(x, 0, 8);
assertRange(y, 0, 8);
const short startX = (x / 3) * 3;
const short startY = (y / 3) * 3;
for (short offset = 0; offset < 9; offset++)
{
if (this->field[startX + (offset % 3)][startY + (offset / 3)] == value)
{
return true;
}
}
return false;
}
and I do run into Segmentationfault Errors. While debugging the blockContainsByBlock function does have a valid this address(eg. 0x778b30). When it calls the blockContains member function the this(inside blockContains) is suddenly a 0x0 address and the code crashes right at the first line. I can provide more code if needed but that is everything that crashes. The parameters are set correctly on each function.
Aucun commentaire:
Enregistrer un commentaire