forked from Waleon/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
24 lines (16 loc) · 577 Bytes
/
main.cpp
File metadata and controls
24 lines (16 loc) · 577 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "singleton.h"
#include <iostream>
using namespace std;
Singleton::GC Singleton::GC::gc; // 重要
int main()
{
//Singleton single = Singleton::GetInstance();
//Singleton *pSingleton1 = Singleton::GetInstance();
//Singleton *pSingleton2 = Singleton::GetInstance();
//cout << (pSingleton1 == pSingleton2) << endl;
//Singleton::GetInstance().doSomething(); // OK
//Singleton single = Singleton::GetInstance(); // Error 不能编译通过
Singleton::GetInstance();
//Singleton::GetInstance()->DestoryInstance(); // 手动释放
return 0;
}