So this will compile in C++, but not Java?? Why doesn't JAVA accept this,but C++ does?
In case of java, once ouch is declared at 1 it can't be declared again at 2 because ouch is considered local to function block/scope and for loop come under that scope. So, you can't declare same variable two times in the same block/scope.
In case of c++, I think for loop may be considered as different scope to the compiler. So, may be redeclaration is not a problem.
Variables and functions are accessed using scoping rules, not visbility rules, in C++, int ouch is decleared as function parameter and again in side the for loop,
the scope of the variable is fixed inside the braces, it is allow in C++ but not in java.