Getter de tableau de pointeur
Bonjour!
Je suis actuellement en train de programmer un jeu d’échec en C++. La board est une classe de type ChessBoard contenant un tableau de pointeur sur Piece (la classe abstraite sur lequel les classes propres à chaque type de pièces vont hérités).
Je cherche à faire un simple getter sur ce tableau privé. Je me heurt à un problème quand au type de la méthode de ce getter.
voici ma classe ChessBoard:
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
class ChessBoard
{
private:
Piece* board[8][8];
void initBoard();
public:
ChessBoard(void);
~ChessBoard(void);
Piece* getBoard();
}; |
et l'implémentation de ma classe:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
ChessBoard::ChessBoard(void)
{
initBoard();
}
ChessBoard::~ChessBoard(void)
{
}
void ChessBoard::initBoard()
{
this->board[0][0] = new Tower("W");
this->board[0][1] = new Horse("W");
this->board[0][2] = new Bishop("W");
this->board[0][3] = new Queen("W");
this->board[0][4] = new King("W");
this->board[0][5] = new Bishop("W");
this->board[0][6] = new Horse("W");
this->board[0][7] = new Tower("W");
this->board[1][0] = new Pawn("W");
this->board[1][1] = new Pawn("W");
this->board[1][2] = new Pawn("W");
this->board[1][3] = new Pawn("W");
this->board[1][4] = new Pawn("W");
this->board[1][5] = new Pawn("W");
this->board[1][6] = new Pawn("W");
this->board[1][7] = new Pawn("W");
this->board[2][0] = NULL;
this->board[2][1] = NULL;
this->board[2][2] = NULL;
this->board[2][3] = NULL;
this->board[2][4] = NULL;
this->board[2][5] = NULL;
this->board[2][6] = NULL;
this->board[2][7] = NULL;
this->board[3][0] = NULL;
this->board[3][1] = NULL;
this->board[3][2] = NULL;
this->board[3][3] = NULL;
this->board[3][4] = NULL;
this->board[3][5] = NULL;
this->board[3][6] = NULL;
this->board[3][7] = NULL;
this->board[4][0] = NULL;
this->board[4][1] = NULL;
this->board[4][2] = NULL;
this->board[4][3] = NULL;
this->board[4][4] = NULL;
this->board[4][5] = NULL;
this->board[4][6] = NULL;
this->board[4][7] = NULL;
this->board[5][0] = NULL;
this->board[5][1] = NULL;
this->board[5][2] = NULL;
this->board[5][3] = NULL;
this->board[5][4] = NULL;
this->board[5][5] = NULL;
this->board[5][6] = NULL;
this->board[5][7] = NULL;
this->board[6][0] = new Pawn("B");
this->board[6][1] = new Pawn("B");
this->board[6][2] = new Pawn("B");
this->board[6][3] = new Pawn("B");
this->board[6][4] = new Pawn("B");
this->board[6][5] = new Pawn("B");
this->board[6][6] = new Pawn("B");
this->board[6][7] = new Pawn("B");
this->board[7][0] = new Tower("B");
this->board[7][1] = new Horse("B");
this->board[7][2] = new Bishop("B");
this->board[7][3] = new Queen("B");
this->board[7][4] = new King("B");
this->board[7][5] = new Bishop("B");
this->board[7][6] = new Horse("B");
this->board[7][7] = new Tower("B");
}
Piece* ChessBoard::getBoard()
{
return(this->board);
} |
Sur le return(this->board); dans le getter il me met Error: le type de valeur ne correspond pas au type de fonction sur la première parenthèse.
J'ai bien sur essayé de déclarer la fonction en Piece*** ChessBoard::getBoard() mais cela ne fonctionne pas
Bien sur le type du getter dans le code n'est pas bon mais c'est pour vous donner une idée de la structure du code.
Auriez vous une idée?
Merci d'avance!