There are three kinds of pointers: Owned, Smart/Shared, and Dumb/Interface.
The following are examples of each kind:
Owned: Resource Allocation Is Initialization (RAII)
Shared: Reference Counting
Interface: Clients use and/or copy but never delete.
For the most part in C++, the delete statements should be in destructors. Also, as part of C++ design, it is important to decide the ownership of pointers. Although, you can get C++ code to work by peppering your code with flags and deletes, it is more maintainable to use the above perspective with pointers.
Reference: "C++ Design", Unpublished manuscript by Steve Weinrich.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment