CSDN博客

img cococut

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

发表于2004/7/8 10:41:00  693人阅读

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

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;

 }

0 0

相关博文

我的热门文章

img
取 消
img