This small section shows an implementation of a simple ADT in C++: An array with bounds checking. Its main purpose is to illustrate the need for destructors, copy constructors, and assignment operators to correctly implement a C++ ADT which allocates storage dynamically.
In C++, objects are often copied, on assignment and when passed as parameters. By default, the system does this by simply copying each data field in one object to the same field in another. But if one of the fields is a pointer allocated with new, this simply copies the pointer so that both objects point to the same allocated block. Usually, that's not what you want. To deal with this, C++ allows the programmer to specify how copying is performed so it can always be done correctly.