我有一個很奇怪的問題。命名空間中的抽象方法
我有3個文件:
figure.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
king.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: error: no ‘bool figure::king::canMove(const position&)’ member function declared in class ‘figure::king’
我該怎麼辦? 非常感謝!
命名空間和函數體不需要分號。 – chris 2013-04-10 23:30:38
@chris - 作爲回答 – 2013-04-10 23:46:14
@ZacharyKniebel,我非常懷疑導致錯誤。 – chris 2013-04-10 23:47:15