dp.creational.singleton 看起来是相当简单的,其实暗藏很多玄机。 // singleton.h class USingleton { public: static USingleton *instance() { if (!_current) { _current = new USingleton(); } return _current; } private: explicit USingleton() {} ~USingleton(){} static USingleton *_current; DISALLOW_EVIL_CONSTRUCTOR(USingleton); }; // singleton.cpp USingleton::_current = 0; 先整理资料先,慢慢总结。 To Kill A Singleton