单例
墨五
这个作者很懒,什么都没留下…
展开
-
设计模式-单例模式(二)
Singleton.h #ifndef _SINGLETON_H_ #define _SINGLETON_H_ #include <stdio.h> #include <pthread.h> class Singleton { private: Singleton() { pthread_mutex_init(&mtx,0); } static Singleton *p; public: static pthread原创 2020-05-23 22:40:07 · 139 阅读 · 0 评论 -
设计模式-单例模式(一)
Singleton.h #ifndef _SINGLETON_H_ #define _SINGLETON_H_ #include <stdio.h> class Singleton { protected: Singleton(){} private: static Singleton* p; public: static Singleton* getInstance(); void func1(void); }; #endif Singleton.cpp #in原创 2020-05-23 22:34:22 · 231 阅读 · 0 评论