Skip to content

Instantly share code, notes, and snippets.

@Temptationx
Created December 23, 2013 05:10
Show Gist options
  • Save Temptationx/8091944 to your computer and use it in GitHub Desktop.
Save Temptationx/8091944 to your computer and use it in GitHub Desktop.
class singleton
{
private static singleton *_instance = null;
protected:
singleton()
{
if(_instance)
{
throw std::logic_error("ss");
}
}
~singleton()
{
if(_instance)
{
singleton* instance_copy = _instance;
_instance = nullptr;
delete instance_copy;
}
}
public:
static singleton& getInstance()
{
if(!_instance)
{
_instance = new singleton;
}
return *_instance;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment