// Singleton.h class Singleton { public: static Singleton* Instance(); void helloWorld(); protected: Singleton(); private: static Singleton* instanza; }; // Singleton.cpp #include < iostream> #include "Singleton.h" Singleton* Singleton::istanza = 0; Singleton* Singleton::Instance () { if (istanza == 0) istanza = new Singleton; return istanza; } void Singleton::HelloWorld() { cout << "Hello World!"; } int main() { Singleton *p = Singleton::Instance(); p->HelloWorld(); delete p; }