In VC 6 , the scope of the range is a function of i scope, can still be used for the outer loop variable i that is:
for (int i = 0; i < n; ++i) {
//……
}
cout<<i<<endl;
So the compiler;
for (int i = 0; i < n; ++i) {
//……
}
int i = 5;
So the compiler error.
In DEV C ++ in, I scope is limited to the for loop , namely:
for (int i = 0; i < n; ++i) {
//……
}
cout<<i<<endl;
So the compiler error.
for (int i = 0; i < n; ++i) {
//……
}
int i = 5;
So the compiler through.
The same in VS (vs2015) I also tested, with the results of the above in dec.
----------------
Disclaimer: This article is the original article CSDN bloggers "offer online world", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source and link this statement.
Original link: https: //blog.csdn.net/qq_34611579/article/details/79860516