知了博客

集天地之精华,吸日月之灵气

singleton模式

singleton模式
#include "stdio.h"
class singleton
{
private static singleton instance = new singleton();//不能在这里初始化
singleton(){}
~singleton(){}
public:
static B * getInstance()
{
if(instance == NULL)
instance = new singleton;
return b;
}
};
singleton* singleton::b = NULL; //静态成员初始化, 不初始化会出错
...
分页:« 首页...«1»...尾页 »

日历

<< 2024-11 >>

Sun

Mon

Tue

Wed

Thu

Fri

Sat

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

Powered By Z-Blog 1.8 Arwen Build 90619 Code detection by Codefense  theme by BokeZhuti

Copyright know blog. Some Rights Reserved.站长(msn):webmaster#webgou.info(#换成@) 粤ICP备09183716号