Singleton

唯一のインスタンスが生成されたら、以降はそのインスタンスしか取得できないような構造がSingletonパターン。

5. Singleton パターン | TECHSCORE(テックスコア)

詳細は、
Sample/designpattern/singleton/singleton/src/singleton at master · bg1bgst333/Sample · GitHub

main.cppは、

class_singleton::get_instanceで2回singletonに入れてるが、

$ vi main.cpp 
$ g++ -o main main.cpp singleton.cpp 
$ ./main 
constructor: count = 0
print: count = 1
print: count = 1
$

同じインスタンスを返してるので、countも増えない。

Sample/designpattern/singleton/singleton/src/singleton at master · bg1bgst333/Sample · GitHub