I know why to make default constructor and copy constructor private to implement singleton class in C++. But what I don't understand is that why make copy assignment operator private, because there will not be two existing objects to start with.
My exploration brings two points:
According to Alexandrescu in "Modern C++ Design", the assignment operator to be made private to prevent self-assignment.
Second, according to rule of three, if you define one of ctor, copy ctor and assignment operator for a class, you should define explicitly all three. So, is it a matter of following this rule only.
So, what's your take on this?
S::getInstance() = S::getInstance();
– Martin York