singleton design pattern----------创建型模式之一

该模式很简单,仅列举下列的代码:

class SingleTonClass

{

private:

      static SingleTonClass* singleton;

private:

        SingleTonClass()

      {}

public:

      static SingleTonClass*  GetInstance();

};

SingleTonClass::singleton = NULL;

SingleTonClass * SingleTonClass::GetInstance()

{

        if(singleton == NULL)

            singleton = new SingleTonClass();

        return singleton;

 }

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页