From 207e6f909c424622840841911d65073f35e05826 Mon Sep 17 00:00:00 2001 From: Jakub Vojvoda Date: Fri, 24 May 2019 16:22:47 +0200 Subject: [PATCH] Deletes copy constructor and assignment operator in Singleton class, fixes #3 --- singleton/Singleton.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/singleton/Singleton.cpp b/singleton/Singleton.cpp index 6950c9d..5c66804 100644 --- a/singleton/Singleton.cpp +++ b/singleton/Singleton.cpp @@ -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 )