Consider following code:
for (int i = 0; i < 10; i++)
{
bool b; /* #1 */
if (i == 0)
{
b = true; /* #2 */
}
}
I have set breakpoints at #1 and #2.
The first time (i = 0), b is set to false at #1 and set to true at #2.
The second time (i = 1), b is true at #1.
This doesn't make sense to me, because I assumed that when starting in the second loop (i = 1), b should be false at declaration again.
I assumed that b = false at #1 in the second loop.
Anyone care to explain?