Is there a way to access the value of a local variable that has become hidden inside another scope?

前端 未结 4 467
野的像风
野的像风 2020-12-11 19:38

I know if a variable is global, the you can always access its value by preceding the variable name with ::... but is there a way to access the value of a local

4条回答
  •  一个人的身影
    2020-12-11 20:18

    You could assign the outer x's address to a pointer object, then refer to it via the pointer in the inner scope (assuming you don't have another pointer object of the same name hiding it).

    Or, as long as you're editing the code, you could change the name.

提交回复
热议问题