delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/20/14:53:13

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp,comp.lang.c++
Subject: Re: Scope of a variable
Date: Fri, 20 Jun 1997 10:13:48 -0400
Organization: Cornell University
Lines: 24
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <33AA901C.2460@cornell.edu>
References: <33aa381b DOT 26282298 AT supernews DOT scsn DOT net>
NNTP-Posting-Host: 128
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Chris wrote:
> 
> My question is, what is the exact scope of a variable that is declared
> in a loop?  Just wondering so I'll know what's legal, and what's not.

from the december draft:

3.3.2  Local scope                                 [basic.scope.local]

...

4 Names  declared in the for-init-statement, and in the condition of if,
  while, for, and switch statements are local to the if, while, for,  or
  switch  statement  (including the controlled statement), and shall not
  be redeclared in a subsequent condition of that statement nor  in  the
  outermost  block  (or,  for  the  if  statement,  any of the outermost
  blocks) of the controlled statement; see _stmt.select_.

you can browse it on-line at www.cygnus.com. the reference for
_stmt.select_ above is 

http://www.cygnus.com/misc/wp/dec96pub/stmt.html#stmt.select

  -- Sinan

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019