#ifndef __SINGLETON_H__
#define __SINGLETON_H__
class Singleton
{
private:
static Singleton* instance;
Singleton(){}
public:
static Singleton* getInstance()
{
if (instance == NULL)
{
instance = new Singleton();
}
return instance;
}
~Singleton(){} };
Singleton* Singleton::instance = NULL;
#endif
#include <iostream>
#include "Singleton.h"
using namespace std;
int main()
{
Singleton *p = Singleton::getInstance(); return 0;
}
05-02 14:08