Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!ads.com!killer!usenet From: anders@verity.com (Anders Wallgren) Newsgroups: comp.sys.mac.programmer Subject: Re: MacApp & C++ destructors Message-ID: <1991Apr14.015647.3521@verity.com> Date: 14 Apr 91 01:56:47 GMT References: <1991Apr10.210516.25812@rice.edu> <9827@etsu.CMI.COM> <1991Apr13.235903.26110@ux1.cso.uiuc.edu> Sender: usenet@verity.com (USENET News) Reply-To: anders@verity.com (Anders Wallgren) Organization: Verity, Inc., Mountain View, CA Lines: 22 In-Reply-To: mlanett@yoyodyne.ncsa.uiuc.edu (Mark Lanett) You probably shouldn't use constructors and destructor with classes descended from TObject unless you know that they will always be created with new. I know for a fact that objects instantiated by name (ie., from a 'view' resource) then the constructor will NOT be called, since Object Pascal knows nothing about C++ constructors. I wouldn't be surprised if there was a similar problem with destructors that means you just can't use this C++ feature (don't despair - MacApp 3.0 is being written in C++). MacApp/Object Pascal uses initializers and free methods. Every class descended from TObject has an Initialize method - use this to get your object into a freeable state in case something goes wrong later in the initialization stage. The IYourClass method usually calls it's superclasses IMySuperClass method and then does it's own initialization. Of course, if the object is being instantiated from a view resource, then IRes is used instead of IYourClass. This is one of the penalties of using an Object Pascal library from C++ - you also can't use multiple inheritance and I think overloading is also a no-no. anders