mirror of
https://github.com/huihut/interview.git
synced 2024-03-22 13:10:48 +08:00
26 lines
457 B
C
26 lines
457 B
C
|
//
|
||
|
// Created by xiemenghui on 2018/7/20.
|
||
|
//
|
||
|
|
||
|
#ifndef DESIGNPATTERN_SINGLETON_H
|
||
|
#define DESIGNPATTERN_SINGLETON_H
|
||
|
|
||
|
// 单例模式
|
||
|
class Singleton {
|
||
|
private:
|
||
|
Singleton(){}
|
||
|
~Singleton(){}
|
||
|
Singleton(const Singleton &);
|
||
|
Singleton & operator= (const Singleton &);
|
||
|
|
||
|
public:
|
||
|
static Singleton & GetInstance()
|
||
|
{
|
||
|
static Singleton instance;
|
||
|
return instance;
|
||
|
}
|
||
|
void DoSomething();
|
||
|
};
|
||
|
|
||
|
#endif //DESIGNPATTERN_SINGLETON_H
|