![](/img/trans.png)
[英]Object has type qualifiers that are not compatible with the member function
[英]the object has type qualifiers that are not compatible with the member function sfml overriding draw
我正在使用SFML 2.1,並且想覆蓋drawable :: draw方法:
void AnimatedSprite::draw(sf::RenderTarget& target, sf::RenderStates states) const;
在其實現中,我正在使用具有以下簽名的成員函數:(導致標題錯誤的函數)
const sf::Sprite AnimatedSprite::getCurrent()
在此函數中,我使用另一個具有相似簽名的函數:
const sf::Sprite Animation::getCurrent()
我返回一個非常量Sprite。
我想可能是問題所在,但是為什么呢? 我不能使用非常量變量來繪制我的實體嗎? 如果可以的話,怎么辦?
您是否忘記在getCurrent函數上添加const? 另外,您還返回了Sprite的副本,這是您想要的嗎? 嘗試const sf::Sprite& AnimatedSprite::getCurrent() const
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.