[color=# 000080] shown below in the teaching video program, two of type int * p variables, not an error, is this why? Is to define variables for many times, I think the writing below should be an error, but did not report errors...
I think I should rewrite into like this, so don't complain, good-looking, also please brother, explain, I appreciate the younger brother taught me is too slow, die electricity, several electricity, SCM... What will you do later...
CodePudding user response:
Because he was inside the {}, involving a hidden variables, local variables to redefine will hide at the beginning of the variable, you two variables the same area, can't hide, so an errorCodePudding user response:
This is a question of a scopeDifferent scopes the same symbols to express different entities are permitted
The code inside this sentence to you
Error is within a scope defines the same symbol
No error is the same symbols appear in different scopes
CodePudding user response:
Lz should look for the book entry level learning the knowledge of the scope of the scope of the variableCodePudding user response:
Compound statements are wrapped up the scope of the block scopeTwo p defined in different block scope it is legal
CodePudding user response:
Because p is in a code block, the scope is visible inside a code block; And Q is the scope of the main function can be seen, so is to redefine,P in the for loop is visible in the circulation and use of no problem, the code block (cycle) is not met,