C++抽象类问题
我有一个抽象类,定义如下:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然它不支持
显式
。没关系,因为它可能不会去标准。Apparently it doesn't support
explicit
. It's fine because it probably won't go to the standard.