From 6359620209326543853
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,de99e5c46dfe5a28
X-Google-Attributes: gidf78e5,public
From: Cristian Georgescu <cgeorges@lehman.COM>
Subject: Re: Multiple declarations in for loop?
Date: 1998/05/22
Message-ID: <35657A4B.597@lehman.com>#1/1
X-Deja-AN: 355596406
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
Content-Transfer-Encoding: 7bit
References: <356196A0.4214@lehman.com> <6jsdc4$fvr@engnews1.Eng.Sun.COM> <6jutcg$96n@marianna.psu.edu>
X-Original-Date: Fri, 22 May 1998 09:14:51 -0400
Mime-Version: 1.0
Reply-To: cgeorges@lehman.COM
Content-Type: text/plain; charset=us-ascii
Organization: Lehman Brothers
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANWWsXuEDnX0m9pzZAQHAfgGAlsifgdVAd4saTg1jF5PtZSwxrL+psrFC WH4ialqKIbQzJMNmmsvuub4Mpxv0x0/o =PnE8
Newsgroups: comp.std.c++


> Steve Clamage <clamage@Eng.Sun.COM> wrote:
> : In article 4214@lehman.com, Cristian Georgescu <cgeorges@lehman.com> writes:
> : >> Only one simple-declaration is allowed. The following declares i and j as
> : >> you wish
> : >> for (int i=0, j=0; i<10,j<10; i++, j++) ...
> : >
> : >Is there a reason for this limitation (only one simple declaration);
> : >why not:
> : >
> : > for (int i=0, unsigned int j=0; i<10,j<10; i++, j++) ...
> 
> : You can't write
> :       int i=0, unsigned int j=0;
> : in any context, so it would be odd to allow it in a for-loop header.
> : The comma in a declaration separates declarators, it doesn't end
> : a declaration.

The need to declare more than one local variable in a for loop arises
very ofter, and I was looking for a way to do it.
Of course, one can always surround the for loop in curly brackets.
-- 
                      Cristian Georgescu
_________________________________________________
                      email: CGeorges@lehman.com
                      tel:   (212) 526-3502

    _/      _/_/_/_/  Lehman Brothers
   _/      _/    _/   Equity Finance Systems
  _/      _/_/_/_/    World Financial Center
 _/      _/    _/     200 Vesey Street
_/_/_/  _/_/_/_/      New York, NY 10285.
_________________________________________________
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



