Singleton: How should it be used

后端 未结 24 2226
Happy的楠姐
Happy的楠姐 2020-11-22 04:57

Edit: From another question I provided an answer that has links to a lot of questions/answers about singletons: More info about singletons here:

So I have read th

24条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 05:13

    I still don't get why a singleton has to be global.

    I was going to produce a singleton where I hid a database inside the class as a private constant static variable and make class functions that utilize the database without ever exposing the database to the user.

    I don't see why this functionality would be bad.

提交回复
热议问题