为什么Singleton是比全局对象更好的选择
这个问题在这里已经有了答案:
他们是懒惰的构造:
LargeObject global; // Large object is always constructed.
class LargeObject_Singelton
{
public: static LargeObject& getInstance()
{
static LargeObject instance; // This object is not created until the first
return instance; // time getInstance() is called.
} // If you never use it this can be important.
};
链接地址: http://www.djcxy.com/p/82163.html
上一篇: Why is Singleton a better choice than Global Objects
下一篇: Why is using a Global Variables class (singleton) bad practise?