G
gwowen
you sure they were actually wrong? I thought the definition of C++
changed. C++ wasn't actually standardised at the time, but was defined
by Stroustrup's book.
Correct (though the "Stroustrop's book" in this context isn't D&E,
which is being discussed else-thread.) Standard C++ has always been
"scope is just the loop", but pre-standard C++ -- that described in
The C++ Programming Language 2nd Ed, it lasts till the end of the
inner block in which the for() lives (r6.5.3).
for(init;exp1;exp2)
statement;
used to be equivalent to
init;
while(exp1){
statement;
exp2;
}
Now its equivalent to
{
init;
while(exp1){
statement;
exp2;
}
}
Some compilers (e.g. g++ ) implement both with a switch to select
between them (-ffor-scope)