Thread View: comp.std.c++
1 messages
1 total messages
Started by Read Fleming
Fri, 27 Oct 1995 18:24
Re: Ownership of objects
Author: Read Fleming
Date: Fri, 27 Oct 1995 18:24
Date: Fri, 27 Oct 1995 18:24
26 lines
1632 bytes
1632 bytes
"Taligent's Guide to Designing Programs" (Addison Wesley, 1994) has some things to say about this. Taligent recommends a naming convention for C++ functions that can be summarized as follows: Create... for functions that make a new object that the caller must delete. Copy... for functions that copy an existing object that the caller must delete. Orphan... for functions that pass deletion responsibility to the caller. Adopt... for functions that assume responsibility for deleting objects that have been allocated by the caller. This convention can be extended for argument names; e.g., a constructor for an objects that takes on ownership of the arguments: AndNode::AndNode(Node* adoptedLeftChild, Node* adoptedRightChild) IMHO, object ownership is not a big deal if you conciously design for it, and use conventions like those above to help document the decisions. --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads