CPlusPlusThings/learn_class/modern_cpp_30/memorymodel_atomic/hungrysingleton.cpp

18 lines
250 B
C++

//
// Created by light on 20-2-6.
//
class singleton {
private:
singleton() {}
static singleton *p;
public:
static singleton *instance();
};
singleton *singleton::p = new singleton();
singleton* singleton::instance() {
return p;
}