locale variables

1
2
3
4
5
6
7
8
9
int main ()
{
  int i = 9;

  for (int i = 0; i < 10; i++)
  {
    // Am i able to use the "higher Level" i, not the for-i ??
  }
}


Thanks for response
More information. I don't understand what you are saying.
Am i able to use the "higher Level" i, not the for-i ??
No, the 'inner' i totally hides the 'outer' i
Thank you
Why would you even want to do this? Wouldn't it be better to use a variable name that actually describes what the variable represents? And even if you're hung up on having single-letter variable names, why would you re-use the same letter for two variables, rather than using different ones?
I dont wanna, but i read that in some programming lang exist a synthax to use the outer i in the inner scope so i wanted to know, if it is possible in C++...

Otherwise is it my programmingstyle to build my for loops with an inner-declared "i" as the control variable so when I run through an two-dimensional array it would be nice if I may take the inner "i" and the outer "i" instead of an "i" and a "k" for example
Well then, excuse me for being blunt, but change your style. Reusing the same variable name in an inner scope, hiding the outer scope variable, is a recipe for disaster. It will make it more likely that you'll make mistakes, and more difficult to find them when you do.

Part of the art of being a good programmer is to make your code easy to understand and easy to maintain. Another part is in adopting practices which make it less likely that you will make mistakes.

Don't cling dogmatically to a "personal style" at the expense of good programming techniques.
Topic archived. No new replies allowed.