Avoid Classes with a non-empty Destructor and the default assignment operator or copy Constructor | CAST Appmarq

Avoid Classes with a non-empty Destructor and the default assignment operator or copy Constructor


Rule Definition
If you need a destructor you probably also need a specific operator= and a specific copy constructor. If you need a destructor, it is probably because your are doing some management of resources. Thus it's probable that you will need a copy constructor and override the copy constructor.

Remediation
Prevent default generation of the copy constructor and assignment operator: - Provide your own version - Or declare it private without implementing it to prevent the operation

Reference
"C++ Notes: OOP: Copy Constructors":http://www.fredosaurus.com/notes-cpp/oop-condestructors/copyconstructors.html

Related Technologies
C++

Health Factor

  Total Quality Index


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.

Benchmark Statistics

Global Compliance

97.04%

Total Violations
10,059
Total Opportunities
339,260
Average Violations / App.
76.79
The compliance score represents 1 minus the ratio between the number of times a rule has been violated compared to the number of opportunities in a set of applications that the rule could have been violated.

Industry Insights

Software ISV

98.15%

Telecommunications

95.40%

Select from drop-down

94.72%