posts - 11,comments - 13,trackbacks - 0
 1#ifndef __SINGLE_H__
 2#define __SINGLE_H__
 3
 4class CSingle
 5{
 6protected:
 7    CSingle()
 8    {
 9
10    }

11public:
12    ~CSingle()
13    {
14
15    }

16    static CSingle * Init_Instance();
17public:
18    static CSingle * _instance;
19}
;
20#endif
 1#include "single.h"
 2#include <stdio.h>
 3#include <stdlib.h>
 4
 5CSingle* CSingle::_instance = NULL;
 6
 7
 8CSingle * CSingle::Init_Instance()
 9{
10    if(!_instance)
11    {
12        _instance = new CSingle();
13    }

14    return _instance;
15}

16
17int main(int argc,char * argv[])
18{
19    CSingle* ab = CSingle::Init_Instance();
20}
系统唯一对象定义
posted on 2009-06-18 15:16 Super- 阅读(181) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理