J
John Baro
What are peoples thoughts on the following.
for(int i = 0; i < 100; i++)
{
int b = 10;
}
or
int b;
for(int i = 0; i < 100; i++)
{
b = 10;
}
//b is not needed anywhere else.
I would like to know whether people prefer to declare it outside scope and
and not recreate it each time or the other way.
Personally (There are much more knowledgeable people here than I) I prefer
the first way as it keeps scope "tight".
ie dont declare it where you dont need it.
Cheers
JB
for(int i = 0; i < 100; i++)
{
int b = 10;
}
or
int b;
for(int i = 0; i < 100; i++)
{
b = 10;
}
//b is not needed anywhere else.
I would like to know whether people prefer to declare it outside scope and
and not recreate it each time or the other way.
Personally (There are much more knowledgeable people here than I) I prefer
the first way as it keeps scope "tight".
ie dont declare it where you dont need it.
Cheers
JB