Const mismatches: 2 overloads have no legal conversion for 'this' pointer

Viewed 27997

I'm getting this weird error:

error C2663: 'sf::Drawable::SetPosition' : 2 overloads have no legal conversion for 'this' pointer

I think it has something to do with const mismatches but I don't know where, or why. In the following code I have a vector of shapes and sprites, and when trying to access one of the vectors shapes and calling one of its functions I'm getting the error.

std::vector<sf::Shape> Shapes;
std::vector<sf::Sprite> Sprites;

bool AddShape(sf::Shape& S){
    Shapes.push_back(S); return true;
};
bool AddSprite(sf::Sprite& S){
    Sprites.push_back(S); return true;
};

private:

virtual void Render(sf::RenderTarget& target) const {                
    for(unsigned short I; I<Shapes.size(); I++){
        Shapes[I].SetPosition(
            Shapes[I].GetPosition().x + GetPosition().x,
            Shapes[I].GetPosition().y + GetPosition().y);
        target.Draw(Shapes[I]);
    }
    for(unsigned short I; I<Sprites.size(); I++){
        target.Draw(Sprites[I]);
    }
}

How can I fix this?

1 Answers
Related