板子.h
#ifndef BOARD_H
#define BOARD_H
#include "piece.h"
class Board
{
public:
Board(bool);
//Piece * getPiece(int x, int y){return &pieceboard[x][y];}
};
#endif
板子.cpp
#include "Board.h"
Board::Board(bool fill)
{
...
};
给我错误:'Board'没有命名类型。用 gcc 编译。
编辑:
在我注释掉#include“piece.h”之后编译的代码。显然它有一些未声明的类。
#ifndef PIECE_H
#define PIECE_H
#include "Board.cpp"
class Piece{
public:
virtual bool checkMove(int, int) =0;
bool movePiece(int, int);
int getX(){return x;}
int getY(){return y;}
char getChar(){return image;}
bool getWhite(){return isWhite;}
protected:
int x, y;
char image;
bool isWhite;
};
class Pawn : public Piece{
public:
Pawn(bool, int, int, Board); // ERROR: 'Board' has not been declared
bool checkMove(int, int);
private:
Board * board; }; // ERROR: 'Board' does not name a type
#endif