I am implementing Singleton class in c++ and I am wondering if it is necessary to declare copy constructor and assignment operator as private, in case I have the following implementation
class Singleton{ static Singleton* instance; Singleton(){} public: static Singleton* getInstance(); }; Singleton* Singleton::instance = 0; Singleton* Singleton::getInstance(){ if(instance == 0){ instance = new Singleton(); } return instance; } It seems that I can have only pointer to Singleton and in that case copy constructor is useless, also operator= . So, I can skip declaring these as private, am I wrong ?
=delete;the functions.