Style and performance question
Which is better:
1 2 3 4 5 6 7
|
{
char temporary_char_c;
string temporary_string_s;
for(int i=0; i<some_n; ++i) {
//some code that uses c and s
}
}
|
or
1 2 3 4 5
|
char temporary_char_c;
string temporary_string_s;
for(int i=0; i<some_n; ++i) {
//some code that uses c and s
}
|
#define better
In your first sample, you put the code into a scope, in the second we can only guess it's in a function scope.
both can be assumed to be in the main function. By better, I mean style and performance wise - as the title states.
//some code that uses c and s
`c' is uninitialized, so they are both crap
`c' is uninitialized, so they are both crap |
Sorry, assume they are initialised. What I am trying everyone to look at is the scoping.
Topic archived. No new replies allowed.