You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A **for** loop terminates when a [break](../cpp/break-statement-cpp.md), [return](../cpp/return-statement-cpp.md), or [goto](../cpp/goto-statement-cpp.md) (to a labeled statement outside the **for** loop) within `statement` is executed. A [continue](../cpp/continue-statement-cpp.md) statement in a **for** loop terminates only the current iteration.
95
95
96
-
If `cond-expression` is omitted, it is considered true and the **for** loop will not terminate without a **break**, **return**, or **goto** within `statement`.
96
+
If `cond-expression` is omitted, it's considered `true`, and the **for** loop won't terminate without a **break**, **return**, or **goto** within `statement`.
97
97
98
-
Although the three fields of the **for** statement are normally used for initialization, testing for termination, and incrementing, they are not restricted to these uses. For example, the following code prints the numbers 0 through 4. In this case, `statement` is the null statement:
98
+
Although the three fields of the **for** statement are normally used for initialization, testing for termination, and incrementing, they're not restricted to these uses. For example, the following code prints the numbers 0 through 4. In this case, `statement` is the null statement:
99
99
100
100
```cpp
101
101
#include <iostream>
@@ -125,7 +125,7 @@ By default, under [/Ze](../build/reference/za-ze-disable-language-extensions.md)
125
125
126
126
[/Zc:forScope](../build/reference/zc-forscope-force-conformance-in-for-loop-scope.md) enables standard behavior of variables declared in for loops without needing to specify `/Za`.
127
127
128
-
It is also possible to use the scoping differences of the **for** loop to redeclare variables under `/Ze` as follows:
128
+
It's also possible to use the scoping differences of the **for** loop to redeclare variables under `/Ze` as follows:
129
129
130
130
```cpp
131
131
// for_statement5.cpp
@@ -137,7 +137,7 @@ int main(){
137
137
}
138
138
```
139
139
140
-
This more closely mimics the standard behavior of a variable declared in a **for** loop, which requires variables declared in a **for** loop to go out of scope after the loop is done. When a variable is declared in a **for** loop, the compiler internally promotes it to a local variable in the **for** loop's enclosing scopeeven if there is already a local variable with the same name.
140
+
This behavior more closely mimics the standard behavior of a variable declared in a **for** loop, which requires variables declared in a **for** loop to go out of scope after the loop is done. When a variable is declared in a **for** loop, the compiler internally promotes it to a local variable in the **for** loop's enclosing scope. It's promoted even if there's already a local variable with the same name.
0 commit comments