Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!ll-xn!ames!sdcsvax!ucbvax!hplabs!hpcea!hpfcdc!hpldola!kens From: kens@hpldola.HP.COM (Ken Shrum) Newsgroups: comp.lang.c++ Subject: Re: constructors and instantiation Message-ID: <11430003@hpldola.HP.COM> Date: Fri, 16-Oct-87 14:53:13 EDT Article-I.D.: hpldola.11430003 Posted: Fri Oct 16 14:53:13 1987 Date-Received: Fri, 23-Oct-87 03:24:48 EDT References: <2575@sigi.Colorado.EDU> Organization: HP Logic Design Oper. -ColoSpgs Lines: 30 > I am having difficulty utilizing the Free Store example (8.5.8, pg 280 > of The C++ Programming Language). ... > ... > stamp::stamp (int v) { val = v; //val should not exist since I have not made a call //to new or reserved the space for the object. //obviously it does exist. Is there an implicit //call to new? Should I override new with another //function? How can new be 'intercepted'? In , pg 280 it states explicitly that you must assign to this before any use of member if you wish to override the default action. On pg 164 it is made explicit that any use of a member before such an assignment is undefined. Regarding the other problem, you've allocated a stamp on the stack by writing: stamp foo(10); I believe that assigning a new value to this for objects on the stack is an undefined operation. See pg 163, 164. If you use stamp *foo = new stamp(10); you'll get the behavior you want. Ken Shrum hplabs!hpldola!kens