At 09:59 AM 5/10/99 -0700, Chris Antos wrote:
>> for (int i=1; i<10; i++) { // do some stuff... }
>> for (int i=1; i<10; i++) { // do some other stuff... }
> um, but isn't that illegal C++? you're redeclaring the variable.
No, the original poster is correct. If a variable is declared within
the initializer part of the 'for' statement, the variable's scope
is until the end of the 'for' statement. Ref: "The C++ Programming
Language", section 6.3.3.1.
Most C++ compilers (and programmers) had this wrong, so it's not
quite fair to trash Microsoft for this one. I'd even go further
to comment that IMHO, as far as C++ standards compliance, and
'newer' things like exceptions, templates, namespaces, etc.,
VC++ is better than most. (And this is coming from a Unix bigot
like me.)
> i'm saying i'm thankful that the compiler complains about illegal
> code ...
But it should accept legal code. =-) Anyway, we all know that
supporting multiple compilers (and multiple versions thereof)
can be very difficult. So since VC++ is the most widely used
compiler on Windows by far, I personally agree with Palm's
decision that VC++ should be the targeted environment.
Regards,
-Ade