Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!usc!ucsd!ucbvax!bnrmtl.UUCP!brad From: brad@bnrmtl.UUCP (Brad Fowlow) Newsgroups: comp.lang.c++ Subject: Re: -fthis-is-variable Message-ID: <9004121602.AA01804@bnrmtl.com> Date: 12 Apr 90 16:02:13 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 34 In answer to some questions that have come up lately, here is a quick description abstracted from the C++ manual. I *believe* this stuff works in g++, but I haven't tried it lately. To control allocation and deallocation of objects yourself, declare member operators new and delete: class A { void* operator new(size_t sz); void operator delete (A* p_a); }; Inheritance, access rules, and so on are as for other classes (the size argument is needed because you'd normally define the operator at some base class level and use it for derived classes). The implementation of these functions could just call 'malloc' and 'free', for example, or whatever you want. Once defined, the use of these functions is transparent. Just say 'new A' and you get what you want. A wrinkle: you can overload the operators new and delete. If you declare extra arguments after size_t, say, operator new (size_t, char*); you call that version by saying A* p_a = new ("extra operator new arg") A ( /* ctor arguments */ ); Hope this is enough to get folks going. No guarantees. brad fowlow