【发布时间】:2014-12-27 17:00:46
【问题描述】:
我正在尝试构建一个由棋子组成的棋盘。我得到了这个
class ChessPiece
{
public:
ChessPiece();
virtual ~ChessPiece();
virtual bool movePiece() = 0;
};
还有这个类
class Pawn: public ChessPiece
{
public:
Pawn();
virtual ~Pawn();
bool movePiece();
};
在我的主要工作中,我正在尝试创建一个 ChessPiece 的二维数组,但因为它是抽象的,所以给我带来了问题。
我试过了
ChessPiece** board = new ChessPiece[8][8];
或
ChessPiece*** board = new ChessPiece*[8];
但它似乎不起作用.. 任何帮助将不胜感激 谢谢!
【问题讨论】:
-
ChessPiece*** board = new ChessPiece*[8];万岁,你现在是三星级程序员了。恭喜!
标签: c++ arrays inheritance abstract-class