What is the scope of a while and for loop?
while
for
For example, if I declared an object within the loop, what is its behavior and why?
Just wanted to add that variables declared in the for or while loop are also scoped within the loop. For example:
for (int index = 0; index < SOME_MAX; ++index) { ... } // index is out of scope here.