'Class'不命名类型
'Class' does not name a type
Board.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
代码很好。我想这个错误是由于"piece.h"中隐藏的东西造成的
相关文章:
- '{'标记之前的预期类名,然后在预声明时无效使用不完整的类型'class class_name'
- C2011 'CMemDC':Visual Studio 2019中的'class'类型重新定义
- C++错误:"class name"之前的预期类型说明符
- "class":非法使用此类型作为表达式 如何解决?
- 如何配置 Doxygen 以在"Class Index"中包含类的类型定义?
- 无法将'Class::operator=='从"布尔"类型(类::)(类*)转换为"布尔"类型
- 获取生成错误:错误 C2011:'ProfileSettings':'class'类型重定义
- 'class MyClass' 在尝试定义静态结构实例时不会命名类型
- 'inherit class'中类型 'template class' 引用的初始化无效
- C++模板: <class> 不命名类型
- 无效使用不完整的类型"class..."
- 无效使用不完整的类型"class"
- 错误:返回类型 'class Polar' 不完整,无效使用类型 'polar'
- 无效使用不完整的类型'class QGraphicsRectItem'
- 无效使用不完整的类型'class...'
- 错误:请求“y”中的成员“x”,该成员属于非类类型“class**”
- 我收到错误"无效使用不完整的类型'class map'
- Qt - 无效使用不完整的类型 'class QScrollBar' - 为文本编辑小部件添加水平滚动条
- 如何确定作为void *返回的指针的类型(Class)
- 错误:无效使用了不完整的类型“class Theron::EndPoint”