mirror of
https://github.com/JakubVojvoda/design-patterns-cpp.git
synced 2025-12-16 20:37:05 +03:00
Deletes copy constructor and assignment operator in Singleton class, fixes #3
This commit is contained in:
@@ -18,6 +18,15 @@
|
||||
class Singleton
|
||||
{
|
||||
public:
|
||||
// The copy constructor and assignment operator
|
||||
// are defined as deleted, which means that you
|
||||
// can't make a copy of singleton.
|
||||
//
|
||||
// Note: you can achieve the same effect by declaring
|
||||
// the constructor and the operator as private
|
||||
Singleton( Singleton const& ) = delete;
|
||||
Singleton& operator=( Singleton const& ) = delete;
|
||||
|
||||
static Singleton* get()
|
||||
{
|
||||
if ( !instance )
|
||||
|
||||
Reference in New Issue
Block a user