- If a variable is declared within a block, its scope runs from its declaration to the end of the block
- If a variable is declared outside all blocks (global variable), its scope runs from its declaration to the end of the program
Note that within the scope of the variable other variables with the same name cannot be declared. If the compilers encounters a second variable declaration with the same name it generates an error because of a name conflict.
No comments:
Post a Comment