Path: utzoo!attcan!uunet!mailrus!cs.utexas.edu!usc!snorkelwacker!husc6!endor!siegel From: siegel@endor.uucp (Rich Siegel) Newsgroups: comp.sys.mac.programmer Subject: Re: Problems in ThinkC mixing direct and indirect objects Keywords: direct indirect class definitions address error Message-ID: <4268@husc6.harvard.edu> Date: 27 Sep 90 01:50:30 GMT References: <9200@potomac.ads.com> Sender: news@husc6.harvard.edu Reply-To: siegel@endor.UUCP (Rich Siegel) Distribution: na Organization: Symantec Language Products Group Lines: 36 In article <9200@potomac.ads.com> adiseker@potomac.ads.com (Andrew Diseker) writes: >void IndirectObj::aMethod() >{ > DirectObj *tempObj; > : > tempObj = new( DirectObj ); > tempObj->someMethod(); <<< the debugger stops here with "odd address trap" > : > delete( tempObj ); >} > > where someMethod() is declared and defined in the DirectObj class >definition and code. I changed DirectObj's definition from direct to >indirect, and had no further problems. Shouldn't I be allowed to mix When using direct classes, the responsibility for storage management is yours - you can't use new() and delete(). You might try something like: void IndirectObj::method() { DirectObj *tmp; tmp = NewPtr(sizeof DirectObj); tmp->itsMethod(); DisposPtr(tmp); } The problem does not lie in your mixing of class types; it's that you need to allocate storage for direct classes yourself. R. Rich Siegel Software Engineer Symantec Languages Group Internet: siegel@endor.harvard.edu UUCP: ..harvard!endor!siegel If you have telekinetic powers, raise my hand.