https://img-blog.csdnimg.cn/32db9ce43ef64316a2e37a31f4cee033.gif
编程小鱼酱yu612.com,点击前往

C++的宏函数单例模式

C++的宏函数单例模式




#define DECLARE_SINGLETON( class_name )																	\
	public:																								\
	static class_name * instance()																		\
		{ if ( 0 == _object ){ _object = new class_name; } return _object; }							\
	static void		  uninit_object()																	\
		{ if ( 0 != _object ){ delete _object; _object = 0; } }											\
	static void		  init_object()																		\
		{ uninit_object(); }																			\
	private:																							\
	static class_name * _object;																		\


#define IMPLEMENT_SINGLETON( class_name )																\
	class_name * class_name::_object = 0;	


posted @ 2017-01-17 08:59  鱼酱  阅读(248)  评论(0编辑  收藏  举报

https://img-blog.csdnimg.cn/32db9ce43ef64316a2e37a31f4cee033.gif
编程小鱼酱yu612.com,点击前往