ByoTic
ByoTic

Reputation: 103

the object has type qualifiers that are not compatible with the member function sfml overriding draw

I'm using SFML 2.1 and want to override the drawable::draw method:

void AnimatedSprite::draw(sf::RenderTarget& target, sf::RenderStates states) const;

In its implementation, I'm using the a member function with the following signature: (the function that causes the title's error)

const sf::Sprite AnimatedSprite::getCurrent()

In this function I use another function with similar signature:

const sf::Sprite Animation::getCurrent()

where I return a non-const Sprite.

I guess it might be the problem, but why? Can't I use a non-const variable to draw my entity with? And if I can, how?

Upvotes: 0

Views: 2321

Answers (1)

Neil Kirk
Neil Kirk

Reputation: 21773

Did you forget to add const on the getCurrent function? Also you are returning a copy of the sprite, is that what you intended? Try const sf::Sprite& AnimatedSprite::getCurrent() const

Upvotes: 1

Related Questions