Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!rutgers!mcnc!uvaarpa!murdoch!hopper.cs.Virginia.EDU!dpc8v From: dpc8v@hopper.cs.Virginia.EDU (Douglas P. Coppage) Newsgroups: comp.lang.c++ Subject: More woes assigning to "this" Keywords: g++, this, help! Message-ID: <1990Jul5.142532.10722@murdoch.acc.Virginia.EDU> Date: 5 Jul 90 14:25:32 GMT Sender: news@murdoch.acc.Virginia.EDU Reply-To: dpc8v@hopper.cs.Virginia.EDU (Douglas P. Coppage) Distribution: na Organization: University of Virginia Computer Science Department Lines: 19 I am using g++ version 1.37.1 on a NeXT. My application requires that objects of a certain class (call it "fido") have data structures of differing sizes. That is, the constructor for fido will have, as one of its parameters, the number of bytes that should be allocated for the new fido's data. I have tried to overload new(), but v. 1.37 yields a parse error when I use the syntax shown in the C++ books I use; I think new() can be overloaded only in v. 2.0+. I have also used the "-fthis-is-variable" compiler directive, and sure enough: the compiler allows assignments to "this", but the assignment does not survive the change in scope! Once I return from the constructor to the caller, "this" is has the value it did at the beginning of the constructor, not the value I assigned it later on in the constructor. I have tried to find on-line information about g++, but none is available. Question: Am I stuck? Can I get g++ to create new fidos of varying sizes? E-mail responses will be greatly appreciated. Doug Coppage (dpc8v@virginia.edu)