Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!hao!oddjob!gargoyle!ihnp4!homxb!mtuxo!mtune!codas!usfvax2!ateng!chip From: chip@ateng.UUCP (Chip Salzenberg) Newsgroups: comp.lang.c++ Subject: Re: constructors and instantiation Message-ID: <51@ateng.UUCP> Date: Tue, 20-Oct-87 10:40:27 EST Article-I.D.: ateng.51 Posted: Tue Oct 20 10:40:27 1987 Date-Received: Sun, 25-Oct-87 01:00:35 EST References: <2575@sigi.Colorado.EDU> Reply-To: chip@ateng.UUCP (Chip Salzenberg) Distribution: na Organization: A.T. Engineering, Tampa, FL Lines: 34 In article <2575@sigi.Colorado.EDU> chase@boulder.Colorado.EDU (Chase Turner) writes: >b) I want to instantiate objects in shared memory which is accessable to >seperate processes No problem. >c) why is the value of *this* not updated in the main body to reflect the >assignment of the object to the malloc space I created? Because the value of "this" is only modifiable for dynamically allocated objects. The "new" operator automatically invokes the appropriate constructor, so given the constructor you posted, you're in like a porch climber. (Except for the first assignment to val, which is a nono.) >main() >{ > stamp ts (10); > ts.print_myself (); >} This should be main() { stamp *ts = new stamp(10); ts->print_myself(); delete ts; } -- Chip Salzenberg "chip@ateng.UUCP" or "{uunet,usfvax2}!ateng!chip" A.T. Engineering My employer's opinions are not mine, but these are. "Gentlemen, your work today has been outstanding. I intend to recommend you all for promotion -- in whatever fleet we end up serving." - JTK