Article View: comp.std.c++
Article #1606Re: Example in "The C++ Workbook" by Wiener and Pinson
From: Warner Losh
Date: Fri, 04 Aug 1995 21:31
Date: Fri, 04 Aug 1995 21:31
35 lines
1349 bytes
1349 bytes
In article <3vtat5INNovr@hubble.asymetrix.com>, Michael Taylor <michaelt@asymetrix.com> wrote: >fenster@shadow.cs.columbia.edu (Sam Fenster) wrote: >>a2675528@athena.rrz.Uni-Koeln.DE (Paul Sponagl) writes: >>> a ^=b; b^=a;a ^=b; >>This sets `a' and `b' to zero if they refer to the same object. > >Wrong! > >Let a = 1001110 >and b = 1001110 > >a ^= b; // -> a = 0 >b ^= a; // -> b = 1001110 >a ^= b; // -> a = 1001110 No. If a and be are the same object then you'll get a ^= a // (a = 0); a ^= a // (a = 0); a ^= a // (a = 0); Which is incorrect! Notice he didn't say same value, he said same object. It also doesn't work if ^= isn't defined on the type. Warner -- Warner Losh "VMS Forever" home: imp@village.org Cyberspace Development, Inc work: imp@marketplace.com Makers of TIA, The Internet Adapter. http://marketplace.com/
Technical Details
Message-ID:
<3vu3js$5s5@rover.village.org>Path:
arc1-ca.pugleaf.net!village.org!not-for-mailReferences:
<3ujj8d$o4m@scapa.cs.ualberta.ca> <3vj9ak$49m@news.rrz.uni-koeln.de> <FENSTER.95Jul31191916@shadow.cs.columbia.edu> <3vtat5INNovr@hubble.asymetrix.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!village.org!not-for-mail From: imp@village.org (Warner Losh) Newsgroups: comp.std.c++ Subject: Re: Example in "The C++ Workbook" by Wiener and Pinson Date: 4 Aug 1995 15:31:40 -0600 Organization: The Village Message-ID: <3vu3js$5s5@rover.village.org> References: <3ujj8d$o4m@scapa.cs.ualberta.ca> <3vj9ak$49m@news.rrz.uni-koeln.de> <FENSTER.95Jul31191916@shadow.cs.columbia.edu> <3vtat5INNovr@hubble.asymetrix.com> NNTP-Posting-Host: rover.village.org