My problem is already solved but I thought I'd post it with the solution since I hadn't found anything on the topic when I did a search earlier.
I have a class derived from Window that overrides the onCreate function:
class MainWindow: public sf::Window
{
public:
MainWindow();
protected:
virtual void onCreate();
};
My original implementation of MainWindow's constructor looked like this:
MainWindow::MainWindow():
sf::Window(sf::VideoMode(640, 480, 32), "SFML Window")
{
}
However my onCreate wasn't getting called. The reason is that virtual functions are not "in effect" until the instance is done initializing, which happens exactly at the opening { of the most derived constructor.
So the simple fix is this:
MainWindow::MainWindow()
{
create(sf::::VideoMode(640, 480, 32), "SFML Window");
}
The Window sub-object is initialized with its default constructor first. That finishes the initialization of the complete object. Only then is the create function called, which calls the intended version of onCreate.
Hope that helps someone!