You can hide a name by declaring it in an enclosed block. In Figure 2.1, i
is redeclared within the inner block, thereby hiding the variable associated with i
in the outer block scope.
Figure 2.1 Block Scope and Name Hiding
The output from the program shown in Figure 2.1 is:
i = 0
i = 7
j = 9
i = 0
Note The argument szWhat
is considered to be in the scope of the function. Therefore, it is treated as if it had been declared in the outermost block of the function.