简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM