Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!apple!keith From: keith@Apple.COM (Keith Rollin) Newsgroups: comp.sys.mac.programmer Subject: Re: MacApp & C++ destructors Message-ID: <51503@apple.Apple.COM> Date: 14 Apr 91 07:25:52 GMT References: <9827@etsu.CMI.COM> <1991Apr13.235903.26110@ux1.cso.uiuc.edu> <1991Apr14.015647.3521@verity.com> Organization: Apple Computer Inc., Cupertino, CA Lines: 27 In article <1991Apr14.015647.3521@verity.com> anders@verity.com (Anders Wallgren) writes: >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++). The fact that MacApp 3.0 is being written in C++ doesn't solve the problem of constructors not being called for TViews created from 'view' resources. Remember that TViews are still descended from PascalObject. Besides, constructors are called "inline" at the point the object is created. In other words, calls to the constructors are determined and inserted at compile time. Since you don't know what views are going to be created from 'view' resource templates until run-time, it will be difficult to call their constructors (though I don't think it would be impossible, and I don't think that such a solution would require MacApp being entirely in C++ anyway). -- ------------------------------------------------------------------------------ Keith Rollin --- Apple Computer, Inc. INTERNET: keith@apple.com UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith "But where the senses fail us, reason must step in." - Galileo