20 lines
293 B
C++
20 lines
293 B
C++
//
|
|
// Created by light on 20-2-6.
|
|
//
|
|
|
|
class singleton {
|
|
private:
|
|
singleton() {}
|
|
static singleton *p;
|
|
public:
|
|
static singleton *instance();
|
|
};
|
|
|
|
singleton *singleton::p = nullptr;
|
|
|
|
singleton* singleton::instance() {
|
|
if (p == nullptr)
|
|
p = new singleton();
|
|
return p;
|
|
}
|