For a reason you posted the source of your function here different than on the page you gave link to:
static Singleton& getInstance(){
static Singleton instance;
return instance;
}
Why does it work? The static local object instance
in the function is created only once, the first time the function is called - that's because it's static
. The next times you call the function it returns reference to the same object.