C ++抽象类问题

时间:2011-03-24 07:03:40

标签: c++ c++11 abstract-class

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

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文件中找不到ScreenLayer.cpp,有几个关于此行{{1}我以前没有尝试使用显式覆盖,但根据C++0x article on wikipedia,你就是这样做的。 VC2010不支持显式覆盖,还是我搞错了其他东西?

提前致谢

1 个答案:

答案 0 :(得分:2)

显然它不支持explicit。这很好,因为probably won't go to the standard