mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-02-03 10:33:25 +08:00
update
This commit is contained in:
22
design_pattern/singleton/static_local_singleton.cpp
Normal file
22
design_pattern/singleton/static_local_singleton.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Created by light on 20-2-7.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class singleton {
|
||||
private:
|
||||
static singleton *p;
|
||||
singleton() {}
|
||||
public:
|
||||
singleton *instance();
|
||||
};
|
||||
|
||||
singleton *singleton::instance() {
|
||||
static singleton p;
|
||||
return &p;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user