面试中遇到了一个手写单例模式的题,在这里总结一下:

 

class CSingleton
{
public:
    static CSingleton* getInstance()
    {
        if (NULL == instance) {
            instance = new CSingleton();
        }
        return instance;
    }

private:
    CSingleton(){}
    virtual ~CSingleton(){}
    static CSingleton* instance;
};

 

相关文章:

  • 2021-09-15
  • 2022-03-02
  • 2021-09-02
  • 2021-09-10
  • 2021-12-06
猜你喜欢
  • 2022-12-23
  • 2021-09-19
  • 2021-04-01
  • 2021-06-26
  • 2021-09-27
相关资源
相似解决方案