如果你要獲取特定的物件
就可以使用 getInstance()
這樣比全域變數看起來舒心一點
e.g. ————————————————————————
// test.h
class SomeService
{
public:
static SomeService &GetInstance();
…
}
// test.cpp
SomeService& SomeService::GetInstance()
{
static SomeService instance;
return instance;
}
————————————————————————
Ref. https://blog.csdn.net/fanyunda1988/article/details/51516930