In member function 'virtual void Button::draw(sf::RenderTarget&, sf::RenderStates) const':
error: passing 'const sf::Text' as 'this' argument of 'void sf::Transformable::setPosition(const Vector2f&)' discards qualifiers [-fpermissive]
And a similar error for the second time I call Text.setPosition()
Edit: Forgot to say that Button gets its draw function from sf::Drawable
I unfortunately can't remove the const in the setPosition function as though it's from a library.
Also, when I try to remove it from the setPosition function, I get an error when I try to use it saying that I can't declare the object to be of abstract type 'Button'
The point is that you seem to try to use non-const qualified objects in your function. So, it is worth a try to remove const from this function, and also virtual, which should take care of the other error. (Likely, anyway.)
I don't think removing const is a good idea. A draw function shouldn't modify the object that is being drawn. The best option would be if you could come up with a way that avoids calling setPosition from inside the Button::draw function.
Actually, even if I do remove the virtual and the const, I still get the abstract type error, (look at my edit) the Button class inherits from sf::Drawable
May I ask why you need to have a separate ButtonPos variable? Can't you just set the position of OptionalText directly?
If you want the Button position to be different from the Text position I would recommend making the variables private (in good OOP style) and adding a Button::setPosition function that takes care of setting the positions correctly. That way the Text position could always be kept correct and would not have to be modified inside the draw function.
Aha! Good idea! Yes, in reality the button class looks like [link=https://pastebin.com/Mb5xGMbR]so[/link] and it's meant to have an optional text inside, and the position for the text would be relative to the Button's position. Thank you! I will edit the setPosition function for the button and add a setTextPosition function. Thanks!