【发布时间】:2013-04-26 05:44:02
【问题描述】:
我有一个很奇怪的问题。
我有 3 个文件:
图.h:
#ifndef FIGURE_H
#define FIGURE_H
namespace figure
{
class figure
{
public:
figure(position &p,color c);
virtual bool canMove(const position &p)=0;
virtual bool move(const position &p)=0;
protected:
color col;
position &p;
};
class king : public figure
{
};
};
#endif // FIGURE_H
国王.h:
#ifndef KING_H
#define KING_H
#include "./figure.h"
namespace figure
{
class king : protected figure
{
};
}
#endif // KING_H
和 king.cpp:
#include "king.h"
bool figure::king::canMove(const position &p)
{
}
我正在编译它: gcc -std=c11 -pedantic -Wall -Wextra
但问题是我收到了这个错误:
/src/figure/figure.h:24:45: 错误: no ‘bool figure::king::canMove(const position&)' 声明的成员函数 类‘figure::king’
我该怎么办? 非常感谢!
【问题讨论】:
-
命名空间和函数体后面不需要分号。
-
@chris - 将其发布为答案
-
@ZacharyKniebel,我非常怀疑这会导致错误。
标签: c++