Add subdirectory for practicing design patterns in C++

+ Add example for singleton
This commit is contained in:
2021-05-11 11:55:21 -04:00
parent 8646cd51ea
commit 248e48d5c9
6 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
#include "singleton.h"
Singleton::~Singleton()
{
// Delete any allocated data, close any opened files, etc..
}
Singleton &Singleton::getInstance()
{
// Construct a new singleton if it doesnt exist, return it
// + If a static Singleton exists already, just return it
static Singleton l;
return l;
}