scope - Programming Scope of Identifiers Prog Fundamentals...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Programming Scope of Identifiers
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Prog. Fundamentals I: Scope of Identifiers/ Slide 2 Scope A sequence of statements within { … } is considered a block of code. The part of the program where you can use a certain identifier is called the scope of that identifier. The scope of an identifier starts immediately after its declaration and ends when the “innermost” block of code within which it is declared ends. It is possible to declare the same identifier in another block within the program.
Background image of page 2
Scope The scope of an identifier does not apply if the same identifier is declared in an inner block. A global declaration of an identifier is made outside the bodies of all functions, including the main function. It is normally grouped with the other global declarations and placed at the beginning of the program file. A local declaration of an identifier is made inside a block of code which could be the body of a function. Globally declared identifiers can be accessed anywhere in the program. Locally declared identifiers cannot be accessed outside
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/07/2011 for the course COMP 102 taught by Professor Daniel during the Spring '08 term at HKUST.

Page1 / 12

scope - Programming Scope of Identifiers Prog Fundamentals...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online