2012年6月13日
摘要: 定义:一个类有且仅有一个实例,并且提供一个访问它的全局访问点。要点:1、类只能有一个实例;2、必须自行创建此实例;3、必须自行向整个系统提供此实例。实现一:单例模式结构代码singleton.h:View Code #ifndef _SINGLETON_H_#define _SINGLETON_H_class Singleton{public: static Singleton* GetInstance();protected: Singleton();private: static Singleton *_instance;};#endifsingleton.cpp:Vie... 阅读全文
posted @ 2012-06-13 22:47 Mike_Zhang 阅读(962) 评论(4) 推荐(0) 编辑