The problem comes from this part
vector<Slider> sliders;
It should be like that.
class Slider{
private:
vector<Slider*> sliders;
}
Map::Map(){
sliders.push_back( new Slider(Vector2f(0, 0)));
sliders.push_back( new Slider(Vector2f(200, 200)));
}
void Map::draw(RenderWindow &window) {
sliders[0]->draw(window);
sliders[1]->draw(window);
}
The problem comes from here.
sliders.push_back(Slider(Vector2f(0, 0)));
It is equivalent to:
Slider s1 = Slider(Vector2f(0, 0));
sliders.push_back(s1);
You create a Slider s1, The sprite of s1 is pointing to the address of the texture inside s1.
Then you push it into the vector, which creates a copy of it. In that case, the Sprite of the new copy is still pointing to the address of the texture inside s1. And when the constructor goes out of scope, ( finishes ), s1 will be destroyed, and vector(i) will have no texture attached.