I am making a chess program and I am having trouble getting the pieces to move when you click on them. I keep getting an error saying "friend declaration specifying a default argument must be a definition". Not sure what is wrong with my code.
for (int y = 0; y < 8; y++) {
for (int x = 0; x < 8; x++) {
board[x][y] = NULL;
}
}
board[0][0] = new Rook(false);
board[7][0] = new Rook(false);
board[0][7] = new Rook(true);
board[7][7] = new Rook(true);
board[0][6] = new Pawn(true);
board[1][6] = new Pawn(true);
board[2][6] = new Pawn(true);
board[3][6] = new Pawn(true);
board[4][6] = new Pawn(true);
board[5][6] = new Pawn(true);
board[6][6] = new Pawn(true);
board[7][6] = new Pawn(true);
board[0][1] = new Pawn(false);
board[1][1] = new Pawn(false);
board[2][1] = new Pawn(false);
board[3][1] = new Pawn(false);
board[4][1] = new Pawn(false);
board[5][1] = new Pawn(false);
board[6][1] = new Pawn(false);
board[7][1] = new Pawn(false);
board[4][7] = new King(true);
board[4][0] = new King(false);
board[3][7] = new Queen(true);
board[3][0] = new Queen(false);
board[2][0] = new Bishop(true);
board[5][0] = new Bishop(true);
board[2][7] = new Bishop(false);
board[5][7] = new Bishop(false);
board[1][0] = new Knight(true);
board[6][0] = new Knight(true);
board[1][7] = new Knight(false);
board[6][7] = new Knight(false);
}
void Piece::draw(int x, int y, QPainter* paint)
{
paint->drawImage(x * 44, y * 44, image);
}
Piece::Piece(bool c)
{
color = c;
}
Rook::Rook(bool c)
: Piece(c)
{
if (color == true) {
image = QPixmap("/Users/oxmem23xo/chess/chess_images/wrook.gif").toImage();
}
else if (color == false) {
image = QPixmap("/Users/oxmem23xo/chess/chess_images/brook.gif").toImage();
}
}
Pawn::Pawn(bool c)
: Piece(c)
{
if (color == true) {
image = QPixmap("/Users/oxmem23xo/chess/chess_images/wpawn.gif").toImage();
}
else if (color == false) {
image = QPixmap("/Users/oxmem23xo/chess/chess_images/bpawn.gif").toImage();
}
}
Knight::Knight(bool c)
: Piece(c)
{
if (color == true) {
image = QPixmap("/Users/oxmem23xo/chess/chess_images/bknight.gif")
.toImage();
}
else if (color == false) {
image = QPixmap("/Users/oxmem23xo/chess/chess_images/wknight.gif").toImage();
}
}
Queen::Queen(bool c)
: Piece(c)
{
if (color == true) {
image = QPixmap("/Users/oxmem23xo/chess/chess_images/wqueen.gif").toImage();
}
It does not state the line where the error is, it just says in the error box this...
friend declaration specifying a default argument must be a definition
friend Q_CORE_EXPORT uint qHash(const Qurl &url, uint seed=0)
Q_DECL_NOTHROW;
^
At this stage I don't think I'm able to help. You need assistance from other mac users of Qt creator. I don't qualify on either hardware or software grounds.
@OP Why not save yourself a whole lot of trouble and just go back to a running version of the program and work from there to replicate the problem. Chances are there will be one additional line that breaks the camels back.
Notwithstanding the unlikely possibility its a Qt version problem, I'd say the problem is elsewhere. So far it is just shooting in the dark.
Qt Creator will provide a reasonably easy to understand error code.
Is this you because the comments there might assist too?
http://stackoverflow.com/questions/41193759/friend-declaration-specifying-a-default-argument-must-be-a-definition-error