Trivial Q about redefinition.

Posted by Knowing me knowing you on Stack Overflow See other posts from Stack Overflow or by Knowing me knowing you
Published on 2010-04-26T10:09:30Z Indexed on 2010/04/26 10:13 UTC
Read the original article Hit count: 117

Filed under:
|

Why this isn't allowed:

int a = 0;
int a = 0;

but this is:

for (int i = 0; i < 2; ++i)
{
    int a = 0;
}

As far as I know code inside for loop will be executed twice whitout actually going out of its scope, so it should also be an error to define a twice.
Looking forward to your answers
Thanks.

© Stack Overflow or respective owner

Related posts about c++

Related posts about definition