C ++ declares variable twice
1 answer
They are two separate variables because they are declared on a different scope . The scope of a variable is the "area" of the code in which it is displayed.
As a simple rule of thumb, any place where curly braces are, or can be placed, is a new region. fly
inside the for loop, overrides another variable fly
. Unless announced or announced under a different name. The original variable will still be available.
+6
source to share