|
|
发表于 2006-4-30 20:41:04
|
显示全部楼层
Post by zlly20
to guyon, 我加了可是还是有错误。
我加了 T* T::smInstance = NULL;
可是编译还是出了问题:
error: `NULL' was not declared in this scope
这个,加上<stddef.h> 或<stdlib.h>试试
Post by zlly20
再请问,如果我想把class的implementation和declaration都放在.h文件里,这个singleton class 的语法是什么?T* T::smInstance = NULL; 这一行应该放在什么地方?
一般实现都放在.cpp中的了,如果想这样做,用模版咯,可以参考一下Loki库 |
|