Hi,
I am writing an application consisting of some files that do inherit from a common base class "Piece". When I try to instantiate an object based on "Piece" inside another class that is also based on "Piece" I get an error like this: "... was not declared in this scope".
I can however instantiate objects from these classes inside other non-related classes. Creating a minimal compilable piece of code to highlight that problem would involve changing the whole code base (bad design :-s) so I just wanted to know if anybody here is able to quickly spot the problem. you can get the sources from here: http://gitorious.org/shatranj/shatranj/trees/master (There is a Download master as tar.gz button on the right side of the page.) Compiling it involves: qmake && make
Here is a piece of code that highlights the problem in "king.cpp"
#include "king.h"
#include "chessboard.h"
// Qt
#include <QPair>
#include <QDebug>
#include "rook.h"
King::King(ChessBoard const* board, Color color, int file, int rank)
: Piece(board, Piece::King, color, file, rank)
, m_hasMoved(false)
{
Rook* r;
}
...
#include "king.h"
#include "chessboard.h"
// Qt
#include <QPair>
#include <QDebug>
#include "rook.h"
King::King(ChessBoard const* board, Color color, int file, int rank)
: Piece(board, Piece::King, color, file, rank)
, m_hasMoved(false)
{
Rook* r;
}
...
To copy to clipboard, switch view to plain text mode
If you remove Rook* r; the code will compile without any further issues. Can anybody tell me what I am doing wrong?
Thanks in advance
Bookmarks