Properly deleting a singleton

前端 未结 5 963
悲&欢浪女
悲&欢浪女 2021-01-24 23:07

I have the following code:

MyClass.h:

static MyMutex instanceMutex;
static MyClass* getInstance();
static void deleteInstance();

MyClas

5条回答
  •  遇见更好的自我
    2021-01-24 23:21

    If it's a singleton - it is defined to have exactly one instance - if you delete it - this drops to 0

    So it seems you should not support delete at all

提交回复
热议问题