简单的单例实现
2014-03-17 09:36
381 查看
//////test.h
//////test.cpp
class test { public: ~test(void); static test* GetInstance(); int Geta(); private: static test m_instance; test(void); int a; };
//////test.cpp
test::test( void ) { a = 10; printf("create test!\n"); } test::~test( void ) { printf("destroy test!\n"); } test* test::GetInstance() { return &m_instance; } int test::Geta() { return a; } test test::m_instance;
void main() { printf("test a:%d\n",test::GetInstance()->Geta()); getchar(); }
相关文章推荐
- 黑马程序员_C语言基本概念
- git 分支管理策略 与 物理实现 --author by阮一峰 & 小鱼
- 黑马程序员_C语言概述
- Linux基础学习(意义、文件系统)
- ecshop的小总结
- 都市感衣橱 权利套装单品举荐女程序猿你值得拥有
- ajax打开一个新页面
- 【黑马程序员】C语言学习笔记之结构体(十二)
- 常用代码片段集锦
- 低内存处理
- QT OSG 浏览器插件 ,将OSG嵌入到IE中
- 3. web前端开发分享-css,js提高篇
- 单播,广播域多播区别及IP范围
- SAS硬盘和SATA硬盘的区别
- J2EE Java黑客大曝光:开发安全的Java应用程序
- 战网登录器:完美解决炉石美台国服三合一
- HTTP 错误 500.19 - Internal Server Error 错误解决方法 集锦iis7(在window7下)
- SQL存储过程-新增和修改,参数Xml数据类型
- 重温数据结构:堆,堆排序,优先队列,TopK问题
- xmpp 01 学习笔记--安装