Skip to content

Instantly share code, notes, and snippets.

@slogic
Created April 3, 2010 13:13
Show Gist options
  • Save slogic/354467 to your computer and use it in GitHub Desktop.
Save slogic/354467 to your computer and use it in GitHub Desktop.
template<class T>
class SingletonObjectFactory {
public:
SingletonObjectFactory() { if(!instance) instance = this; }
~SingletonObjectFactory() { if(instance == this) instance = NULL };
static T* getInstance() { return instance };
private:
static T* instance;
};
template <class T>
T* SingletonObjectFactory<T>::instance = NULL;
template <class T>
T* SingletonObjectFactory<T>::getInstance() {
return instance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment