#include <stdio.h>
class Single{
private:
staticSingle *p;
protected:
Single();
public:
staticSingle *makeSingle();
staticvoid releaseSingle();
};
#include "single.hpp"
#include <iostream>
Single *Single::p =NULL;
Single::Single(){
}
Single *Single::makeSingle(){
if (p ==NULL)
p =newSingle;//如果p为空就实例化对象
returnp;
}
void Single::releaseSingle(){
deletep;
p = NULL;
}
//实例化单例
Single *p =Single::makeSingle();
Single::releaseSingle();