Rule Definition
If you need a copy constructor, you also need a destructor and operator=. If you need a copy constructor, it's because you need something like a deep copy, or some other management of resources. Thus it is almost certain that you will need a destructor and assignment operator.
If you don't need a copy constructor (because the default-generated copy constructor would be correct), you should let the compiler generate it: it will not contain bugs, and you will often not have to update it when the class is modified.
Remediation
Prevent default generation of the destructor and assignment operator:
- Provide your own version
- Or declare it private without implementing it to prevent the operation (for assignment operator)
Reference
"C++ Notes: OOP: Copy Constructors":http://www.fredosaurus.com/notes-cpp/oop-condestructors/copyconstructors.html
Related Technologies
C++
Technical Criterion
CWE-1098 - Data Element containing Pointer Item without Proper Copy Control Element
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.