Singleton pattern in C++

前端 未结 8 1820
北荒
北荒 2020-11-30 18:10

I have a question about the singleton pattern.

I saw two cases concerning the static member in the singleton class.

First it is an object, like this

8条回答
  •  一向
    一向 (楼主)
    2020-11-30 18:19

    Your first example is more typical for a singleton. Your second example differes in that it is created on-demand.

    However I would try to avoid using singletons in general since they are nothing more than global variables.

提交回复
热议问题