Article View: comp.std.c++
Article #2045Re: Scope of variables declared in if/while/for
From: Herb Sutter
Date: Tue, 26 Sep 1995 23:00
Date: Tue, 26 Sep 1995 23:00
28 lines
1565 bytes
1565 bytes
I wrote:
>surprises that used to be legal (e.g. you could have the lifetime and
>scope of an object not end at the same time, and then there was some
>weirdness introduced by the RTTI rules).
That last phrase is shoddy writing. Instead of the sloppy (and wrong) "some
weirdness introduced", Steve said much more clearly:
Steve Clamage wrote:
>3. With the addition of dynamic_cast, it became particularly desirable
>to have limited-scope variables defined in loop or selection statements:
> if( T* p = dynamic_cast<T*>(e) { ... }
> else if( U* p = dynamic_cast<U*>(e) { ... }
>A for-loop variable should then also have limited scope. This was the
>clincher.
Mea culpa!
Herb
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herb Sutter 2228 Urwin, Ste 102 voice (416) 618-0184
Connected Object Solutions Oakville ON Canada L6L 2T2 fax (905) 847-6019
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<199509261828.OAA08814@gold.interlog.com>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 26 Sep 95 23:00:45 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ Message-ID: <199509261828.OAA08814@gold.interlog.com> From: herbs@interlog.com (Herb Sutter) Subject: Re: Scope of variables declared in if/while/for Organization: Connected Object Solutions (div of Daystar Software Systems Design Inc.) X-Original-Date: Tue, 26 Sep 95 18:34:29 GMT