开发者

C++ why is my class still abstract?

开发者 https://www.devze.com 2023-02-19 04:42 出处:网络
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'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

精彩评论

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