Singleton Design Pattern ---------- Created mode

zhaozj2021-02-12  147

This mode is very simple, only listed in the following code:

Class Singletonclass

{

Private:

Static Singletonclass * Singleton;

Private:

Singletonclass ()

{}

PUBLIC:

Static Singletonclass * getInstance ();

}

Singletonclass :: Singleton = NULL;

Singletonclass * singletonclass :: getInstance ()

{

IF (Singleton == Null)

Singleton = new singleletonclass ();

Return Singleton;

}

转载请注明原文地址:https://www.9cbs.com/read-6458.html

New Post(0)