I'm creating a simple Windows Console application and am experiencing a strange error. The program runs fine and does everything without error, but when it hits the final return 0;
in the main routine i get the following error
I've never seen it before and don't know what it means. I tried to read through the documentation but it was not enlightening.
Here's the program. I do some dynamic allocations, so I thought that might be it but I've never gotten this error in the past despite having made plenty of pointer, dynamic allocation, and indexing errors before. It's always seg-faults, syntax, or compilation errors.
const char WHITE = 'x';
const char BLACK = 'o';
const char EMPTY = '-';
const char EDGE = 'e';
struct BoardSpace
{
int x_loc;
int y_loc;
int white_score;
int black_score;
string last_visitor;
char stone;
char owner;
};
class GoBoard
{
private:
void InitBoard(BoardSpace** board)
{
for (unsigned int x = 0; x < BoardSize; x++)
{
board[x][0].stone = EDGE;
board[0][x].stone = EDGE;
board[x][BoardSize - 1].stone = EDGE;
board[BoardSize - 1][x].stone = EDGE;
}
for (unsigned int x = 1; x < BoardSize - 1; x++)
{
for (unsigned int y = 1; y < BoardSize - 1; y++)
{
MyBoard[x][y].stone = EMPTY;
}
}
}
public:
unsigned int BoardSize;
BoardSpace **MyBoard;
GoBoard(int size)
{
BoardSize = size + 2;
MyBoard = new BoardSpace*[BoardSize];
for (unsigned int x = 0; x < BoardSize; x++)
{
MyBoard[x] = new BoardSpace[BoardSize];
}
InitBoard(MyBoard);
}
~GoBoard()
{
for (unsigned int x = 0; x < BoardSize; x++)
{
delete MyBoard[x];
}
delete MyBoard;
}
void PrintBoard()
{
for (unsigned int x = 0; x < BoardSize; x++)
{
for (unsigned int y = 0; y < BoardSize; y++)
{
cout << MyBoard[x][y].stone << ' ';
}
cout << endl;
}
}
};