1

板子.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
4

1 回答 1

-3

代码很好。我猜这个错误是由于潜伏在“piece.h”中的东西造成的

于 2013-08-05T17:06:06.793 回答