开发者

C++ why is my class still abstract?

I'm sure its something simple on my part, but I can't figure out why my compiler thinks one of my classes is abstract. Here's the situation:

I have an abstract base class like so:

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;
};

And I inherit from it as so:

class ScreenLayer : public AnimatedDraw
{
public:
    ScreenLayer(void);

    virtual void Draw(sf::RenderWindow &window);

    virtual void Draw(sf::RenderWindow &window, sf::Shader &shader);

    virtual void Update(sf::Clock &clock);

    ~ScreenLayer(void);
};
开发者_StackOverflow社区

for reference, the ScreenLayer.cpp file 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)
{
}

However, when I try to use my derived class (i.e. AnimatedDraw *testDrawer = new ScreenLayer; ) my compiler complains the ScreenLayer is abstract. Changing AnimatedDraw to ScreenLayer was also invalid for the same reason. I overwrote all the abstract function on my base class didn't I? I'm not sure why it's being seen as abstract. Any help would be appreciated

Thanks


Your base class declaration doesn't have an ampersand after sf::Shader:

virtual void Draw(sf::RenderWindow &window, sf::Shader shader) = 0;

The derived class has, hence it's a different overloaded function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜