Search code examples
c++privatecopy-constructorpublic

Should copy constructor be private or public


I am writing an abstract class that will be a parent for several other classes. I am thinking the copy constructor should be made private because you are using an abstract class and there is nothing to copy. However, I am not a 100% sure.

Am I correct and if I am not why should it be public or protected?


Solution

  • The copy constructor should be private if you do not want objects of the class to be copied. Otherwise, it should be public.