Message-ID: <3688953A.6E209BE8@ulster.net> Date: Tue, 29 Dec 1998 03:39:23 -0500 From: Keith Organization: none X-Mailer: Mozilla 4.04 [en] (Win95; I) MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp To: djgpp AT delorie DOT com Subject: Re: ? strange problem References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Ztream, you're right about this, but i did get the same bug that the origional person was talking about... an integer w/in a class went bad somehow when i was passing it out of a switch statement... i know this is exactly where it happend because i had it "cout" the values at every point in the prog... but the program worked fine when i assigned the origional class to a second class of the same type w/in the switch statement (just before it went bad) and then used that second class outside the switch statement... also, this program compiled fine in the borland compiler w/o this modification... thanks, steve Ztream wrote: > > -----Original Message----- > > From: twidler444 AT aol DOT com [SMTP:twidler444 AT aol DOT com] > > Sent: Monday, December 21, 1998 7:19 AM > > To: djgpp AT delorie DOT com > > Subject: Re: ? strange problem > > > >Hello > > I couldn't find the earlier posting, But I think I know what you > are talking > >about, and how to fix it. > > >does your code look something like this? > > >typedef struct TEST > >{ > >int x,y; > >}TEST; > > > >TEST it; > > > >int main() > >{ > >TEST temp; > > > >temp=it; > >temp.x=10; > >temp.y=50; > > > >// then here is were you find out that it.x isnt 10 > >} > > The reason it.x isn't 10 is because it is simply never set to 10. temp is > not a pointer. temp=it copies all member fields from "it" to temp, but temp > is still a completely independent variable; what you do to temp does not and > should not affect "it" in any way. > > I guess that what you mean to do is something like the following: > > int main() > { > TEST *temp; > > temp=⁢ > temp->x=10; > temp->y=50; > } > > This correctly alters "it" as you are altering temp->x. > > >I found that in DJGPP(and other free compilers) that you can only > read from > >temp.x and not write. > > I feel rather confident that the above should not work under *any* compiler > (*that* would be a bug). Please correct me if I'm wrong, but I tested both > your original code and my altered code, and they both confirmed what I'm > saying. > > Or, perhaps you just made an error in the comment on the last line, actually > meaning temp.x ;) This does, however, work as expected, and the rest of the > mail seems to confirm that you do mean what you typed. > > Hope this is of help :) > > / Z > > --------------------------------------------------------------------------- > Ztream / 1x4x9 - "The white dwarf" > ztream AT x3m DOT se \ www.highrad.x3m.se/Ztream > Free your mind.