mirror of
https://github.com/JakubVojvoda/design-patterns-cpp.git
synced 2025-12-16 20:37:05 +03:00
fix Singleton pattern
This commit is contained in:
@@ -28,19 +28,19 @@ public:
|
||||
std::cout << "This is Singleton." << std::endl;
|
||||
// ...
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
private:
|
||||
Singleton() {}
|
||||
static Singleton *instance;
|
||||
// ...
|
||||
};
|
||||
|
||||
Singleton* Singleton::instance = nullptr;
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
Singleton singleton;
|
||||
singleton.tell();
|
||||
|
||||
Singleton::get()->tell();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user