C++ allows you to declare variables wherever you need them, thus enabling immediate initializations. A good example is a loop counter. It can (and should) be declared inside a for-statement:
void f() {for (int i = 0; i < 10; i++) // i declared and initialized inside a for-statement{ cout << i <
In earlier stages of C++, a local variable declared this way remained accessible in its enclosing block. This was a source for bugs and name hiding. Consequently, the standard has been revised to fix this loophole, so to speak, and local variables created this way are inaccessible outside the for-statement in which they were declared. In the example above, i is inaccessible outside the loop.