Any class that has memory to manage should provide all the methods necessary to properly manage that memory, including a copy constructor and an override of ``++operator=++``. Without those methods, you're likely to end up with memory leaks and multiple class instances pointing at the same segments of memory for their members.


== Noncompliant Code Example

----
class MyClass // Noncompliant
{
  private: 
    char* cpData;
  public
    MyClass(const char* value);
    ~MyClass();
}

MyClass a = new MyClass("The quick red fox");
MyClass b = new MyClass("How now brown cow");

b = a;  // cpData pointer, not value copied. Also b's old value not deleted: Memory leak.
----


== See

* https://www.securecoding.cert.org/confluence/x/SAAV[CERT, OOP-06-CPP.] - Create a private copy constructor and assignment operator for non copyable objects


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
