- Nov 29, 2005
- 2,411
- 0
- 0
Simple question:
I usually avoid inline variable declarations, and prefer to stick them at the top of my function. Probably for cleanliness' sake, and probably because I started with C, not C++.
But I notice sometimes I wonder if a variable was initialized, or [egads] what its for, or what type it is and stuff. Now, hopefully a lot of this can be gleaned from context and the variable name (I'm getting better about calling things "arrayIndexCounter" instead of "temp") but in some sense, it makes sense to have variables that are just going to be used "right now" (i.e. as I'm coding) declared right before I'm using them.
So the question is whether or not this is considered bad form (or maybe I'm so out of the loop it's considered bad for not to? Who knows?)
I usually avoid inline variable declarations, and prefer to stick them at the top of my function. Probably for cleanliness' sake, and probably because I started with C, not C++.
But I notice sometimes I wonder if a variable was initialized, or [egads] what its for, or what type it is and stuff. Now, hopefully a lot of this can be gleaned from context and the variable name (I'm getting better about calling things "arrayIndexCounter" instead of "temp") but in some sense, it makes sense to have variables that are just going to be used "right now" (i.e. as I'm coding) declared right before I'm using them.
So the question is whether or not this is considered bad form (or maybe I'm so out of the loop it's considered bad for not to? Who knows?)