Copy Constructor and Assignment Operator

Question asked in test. Please help.

Last edited on
A class needs copy constructor and assignment operators if the class has some pointer objects, in which case the bitwise copy might corrupt your program.
I the class doesn't contain any pointer variable then there is no need for copy cons or assignment op as the compiler shall provide a default optimized one...
However, there are times when a compiler will refuse to provide a default constructor or assignment operator.

For example when the class contains
1. references
2. constant members.

EDIT:
But I think that it (the compiler) can always magage to produce a default copy constructor *(which may or may not suit your purposes).
Last edited on
Topic archived. No new replies allowed.