Practical Considerations: What to Implement

Dynamic memory management has to be handled with knowledge and understanding. Step to either side and you risk either performance degradation or integrity loss.

Many programmers believe that each time you design a class that manages memory dynamically, you must provide this class with the full complement of auxiliary member functions:

  • default constructor

  • conversion constructor(s)

  • copy constructor

  • overloaded assignment operator(s)

  • destructor

I am not sure you have to automatically follow this recommendation. Depending on client code requirements, you might need only part of these functions. If you supply operators with the wrong interfaces, you will eliminate the integrity problem, but you also will impair ...

Get Core C++ A Software Engineering Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.