bool status = true;
if (status == true)
{
for (int status = 0; status < 1; status++)
{
}
}
in this case status is already declared in the if block, so it can not be declared in the child block (i.e. For block).
Every variable has a scope associated with it, and it is limited to the block in which it is declared.
e.g.
static main()
{
{
int i = 0;
}
}
With this, no two variables with the same name can be declared in the scope. If you do so, you get an error saying : "A local variable named 'xyz' cannot be declared in this scope because it would give a different meaning to 'xyz' , which is already used in a 'parent or current' scope to denote something else"