Need of privatizing assignment operator in a Singleton class

前端 未结 7 947
一生所求
一生所求 2021-01-18 04:01

Can someone justify the need of privatizing the assignment operator in a Singleton class implementation?

What problem does it solve by making Singleton& o

7条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-18 04:25

    If you only want one instance, the copy constructor should be private. The assignment operator access specifier does not matter, because it will be impossible to use anyway.

提交回复
热议问题