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; //静态成员初始化, 不初始化会出错
...