Scope of Variables Declared in for()
The new ANSI C++ standard specifies that variables declared as in for(int i=1; ...) have a scope local to the for statement. Unfortunately, older compilers (like Visual C++ 5.0) use the older concept that the scope is the enclosing group. Below, I list two possible problems arising from this change and their recommended solutions.
Say you want to use the variable after the for() statement. You would have to declare the variable outside...
Simple Programming Tips On C/C++
The new ANSI C++ standard specifies that variables declared as in for(int i=1; ...) have a scope local to the for statement. Unfortunately, older compilers (like Visual C++ 5.0) use the older concept that the scope is the enclosing group. Below, I list two possible problems arising from this change and their recommended solutions.
Say you want to use the variable after the for() statement. You would have to declare the variable outside...
Simple Programming Tips On C/C++