What's the use of the private copy constructor in c++

后端 未结 7 1396
抹茶落季
抹茶落季 2020-11-29 23:44

Why do people define a private copy constructor?

When is making the copy constructor and the assignment operator private a good design?

If there are no membe

7条回答
  •  隐瞒了意图╮
    2020-11-30 00:31

    Even if the contents of the object aren't pointers or other references, preventing people from copying the object can still be useful. Perhaps the class contains a lot of data, and copying is too heavyweight of an operation.

提交回复
热议问题