Make a concious choice between value or reference behavior for your classes.
-
To implement value semantics you endow the class with correct copy, assignment, and destruction operations that keep the class's state
distinct for each of its instances. If all the objects held by your class, as data members, have correct copy, assignment,
and destruction semantics, then the default operations provided by the compiler will be correct and you don't declare those operations.
-
You implement reference semantics by sharing state among instances via pointers and managing their destruction with reference counting.
Copy, assignment, and destruction must be explicitly defined by your class to support this sharing.
-
In the rare cases when you do not wish to enforce either value or reference semantics you declare
a copy constructor and assignment operator as private. This causes compile failure if a user tries to assign or construct from a copy.
You should also avoid providing any implementation so that if your class code does an implicit copy or assignment the package will suffer
a linking failure during build.