You want to create the window in the constructor of the class instead of at the time of declaring the variable?
You can specify the parameters in the construction of it in the constructor's member initializer list:
class Game
{
public:
Game();
private:
sf::RenderWindow window;
}
Game::Game()
: window(sf::VideoMode(800, 600), "Game")
{
}
or, as sjaustirni said, you can later create the window - or recreate an already-created window - by using window's create() method.
Same example as above but this time using the create method:
class Game
{
public:
Game();
private:
sf::RenderWindow window;
}
Game::Game()
{
window.create(sf::VideoMode(800, 600), "Game");
}