【发布时间】:2016-12-02 14:31:12
【问题描述】:
我查看了 stackoverflow 中的类似问题,但还没有找到答案。
这是我的子类声明:
class Enemy : public Entity
{
public:
Enemy();
~Enemy();
}; // This is the line that shows the error...
这是我的超类声明:
class Entity
{
//Member Methods:
public:
Entity();
~Entity();
bool Initialise(Sprite* sprite);
void Process(float deltaTime);
void Draw(BackBuffer& backBuffer);
void SetDead(bool dead);
bool IsDead() const;
bool IsCollidingWith(Entity& e);
float GetPositionX();
float GetPositionY();
float GetHorizontalVelocity();
void SetHorizontalVelocity(float x);
float GetVerticalVelocity();
void SetVerticalVelocity(float y);
protected:
private:
Entity(const Entity& entity);
Entity& operator=(const Entity& entity);
//Member Data:
public:
protected:
Sprite* m_pSprite;
float m_x;
float m_y;
float m_velocityX;
float m_velocityY;
bool m_dead;
private:
};
我已经有一个名为 playership 的子类,它使用相同的结构,但它工作正常。那么哪里出了问题呢?
【问题讨论】:
-
向我们展示导致此错误的确切代码行。
-
这不是显示错误的相关代码。显示显示错误的代码。这是一个非常基本的错误。
-
这是 Enemy 类中的最后一行,在 } 之后; @Ajay 提前致谢!
-
它已更新,@TerraPass 谢谢!
-
@Wilheim Cannot duplicate。请发布实际上无法编译的代码,而不是我们不得不猜测它是什么。
标签: c++ inheritance subclass superclass