Original Post
I have had 2 basic questions that I have always avoided, and did it my way, so I may as well ask them to see what is correct Snippet 1: use this: or this: Snippet 2: use this: or this: Note these are just samples, I am using them in much more complex terms as well as simple ones like this. in both cases, I always went for the top case for both snippets, but in some cases the bottom one can be cleaner. What is faster/better/stronger?
int variable;
for(int y =0; y < 100; y++)
{
variable = [anything];
}
for(int y =0; y < 100; y++)
{
int variable = [anything];
}
int variable = [anything];
int variable2 = [anything] + 1;
both are used throughout a entire class
int variable = [anything];
used throughout the class, but when we come to a place that needs what was variable2, just have variable + 1