JOKER_JOKER
Limp Gawd
- Joined
- Nov 2, 2005
- Messages
- 471
In my chess program I have a base class called Piece with 6 subclasses of each piece type (King, Queen, Rook, Knight, Bishop, Pawn), as well as a class called Game, which handles all of the gameplay. In my Game class header, I declare a two dimensional array Pieces (Piece* Board[8][8]). The problem I'm running into is that I can't figure out how to call that array while in a subclass of Piece. For instance, in my Queen class, I'm trying to access and alter the Board, but I keep getting errors. I know the problem is probably a simple one, but I can't seem to figure it out, any ideas?
Header of my Game class
The Move function from my Queen class
Header of my Game class
Code:
class Game
{
public:
Game();
void StartGame();
void DrawBoard();
bool IsCheckMate();
Piece* Board[8][8];
};
The Move function from my Queen class
Code:
void Queen::Move(int desx, int desy)
{
Board[desy][desx] = *this;
Board[LocY][LocX] = NULL;
}