C++抽象类问题

发布于 2024-10-26 12:34:18 字数 1384 浏览 3 评论 0原文

我有一个抽象类,定义如下:

class AnimatedDraw
{
public:
    virtual void Draw(sf::RenderWindow &window) = 0;
    virtual void Draw(sf::RenderWindow &window, sf::Shader shader) = 0;
    virtual void Update(sf::Clock &time) = 0;
};

我试图从它继承到另一个类,定义如下:

class ScreenLayer explicit : public AnimatedDraw
{
public:
    ScreenLayer(void);
    virtual void Draw(sf::RenderWindow &window) override; //I'll need to be able to override these again in subclasses
    virtual void Draw(sf::RenderWindow &window, sf::Shader &shader) override;
    virtual void Update(sf::Clock &clock) override;
    ~ScreenLayer(void);
};

源文件现在是空函数,如下所示:

#include "ScreenLayer.h"
ScreenLayer::ScreenLayer(void)
{
}
void ScreenLayer::Draw(sf::RenderWindow &window)
{
}
void ScreenLayer::Draw(sf::RenderWindow &window, sf::Shader &shader)
{
}
void ScreenLayer::Update(sf::Clock &clock)
{
}
ScreenLayer::~ScreenLayer(void)
{
}

我做错了什么,因为我的编译器(VC2010)产生多个错误,包括抱怨在 ScreenLayer.cpp 文件中找不到 ScreenLayer,以及有关此行 class ScreenLayer 显式 : public AnimatedDraw 的几个错误> 我之前没有尝试过使用显式覆盖,但是根据 C++0x维基百科上的文章,这就是你的做法。 VC2010 不支持显式覆盖吗,还是我搞砸了其他东西?

提前致谢

I have an abstract class defined as follows:

class AnimatedDraw
{
public:
    virtual void Draw(sf::RenderWindow &window) = 0;
    virtual void Draw(sf::RenderWindow &window, sf::Shader shader) = 0;
    virtual void Update(sf::Clock &time) = 0;
};

I'm trying to inherit from it into another class defined as follows:

class ScreenLayer explicit : public AnimatedDraw
{
public:
    ScreenLayer(void);
    virtual void Draw(sf::RenderWindow &window) override; //I'll need to be able to override these again in subclasses
    virtual void Draw(sf::RenderWindow &window, sf::Shader &shader) override;
    virtual void Update(sf::Clock &clock) override;
    ~ScreenLayer(void);
};

The source file is empty functions right now and is as follows:

#include "ScreenLayer.h"
ScreenLayer::ScreenLayer(void)
{
}
void ScreenLayer::Draw(sf::RenderWindow &window)
{
}
void ScreenLayer::Draw(sf::RenderWindow &window, sf::Shader &shader)
{
}
void ScreenLayer::Update(sf::Clock &clock)
{
}
ScreenLayer::~ScreenLayer(void)
{
}

I'm doing something wrong, as my compiler (VC2010) produces several errors, including complaining it can't find ScreenLayer in the ScreenLayer.cpp file, and several about this line class ScreenLayer explicit : public AnimatedDraw I haven't tried to use explicit overrides before, but according to the C++0x article on wikipedia, that is how you do it. Does VC2010 not support explicit overrides, or did i mess something else up?

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

擦肩而过的背影 2024-11-02 12:34:18

显然它不支持显式。没关系,因为它可能不会去标准

Apparently it doesn't support explicit. It's fine because it probably won't go to the standard.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文