I've found this singleton example in C++ language:
#include <iostream>
class singleton {
private:
    // ecco il costruttore privato in modo che l'utente non possa istanziare direttamante
    singleton() { };
public:
    static singleton& get_instance() 
    {
            // l'unica istanza della classe viene creata alla prima chiamata di get_instance()
            // e verrà distrutta solo all'uscita dal programma
        static singleton instance;
        return instance;
    }
    bool method() { return true; };
};
int main() {
    std::cout << singleton::get_instance().method() << std::endl;
    return 0;
}
But, how can this be a singleton class?
Where is the control of only one istance is created?
Do not miss a static attribute?
What happens if in main function I write another get_instance() call?
 
     
     
    