Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uunet!bywater!arnor!watson!blinn.watson.ibm.com!mittle From: mittle@blinn.watson.ibm.com (Josh Mittleman) Newsgroups: comp.lang.c++ Subject: Re: General approaches to some common (for me) situations... Message-ID: <1991Apr22.125549.11558@watson.ibm.com> Date: 22 Apr 91 12:55:49 GMT References: Sender: @watson.ibm.com Organization: IBM T. J. Watson Research Lines: 17 The first problem you describe is one of the reasons that exception handling is being introduced into the language. See ARM, 353ff for a thorough discussion. Without exception handling there are lots of kluges to deal with the situtation you describe: error code members, static error code variables, etc. In the second part of your post, it sounds like you really need a class SetOfB which manages all of the allocation and deallocation of B's. Class A contains a SetOfB and can add B's to it. In A's destructor, you destroy the SetOfB, which in turn destroys all the B's currently in the set. If some other class C needs to reference the same SetOfB, then you have to decide whether the A or the C owns the SetOfB. Assuming that the A owns it, the C should have a pointer to the SetOfB, or perhaps just to the A. =========================================================================== Josh Mittleman (mittle@watson.ibm.com or joshua@paul.rutgers.edu) J2-C28 T.J. Watson Research Center, PO Box 704, Yorktown Heights, NY 10598