Skip to content

Commit f089700

Browse files
committed
fix Singleton pattern
1 parent 931fdb5 commit f089700

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

singleton/Singleton.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ class Singleton {
2828
std::cout << "This is Singleton." << std::endl;
2929
// ...
3030
}
31-
3231
// ...
3332

3433
private:
34+
Singleton() {}
3535
static Singleton *instance;
3636
// ...
3737
};
3838

39+
Singleton* Singleton::instance = nullptr;
40+
3941

4042
int main()
4143
{
42-
Singleton singleton;
43-
singleton.tell();
44-
44+
Singleton::get()->tell();
4545
return 0;
4646
}

0 commit comments

Comments
 (0)