Storage classes and Lifetime

Storage classes and Lifetime - 7: Storage Classes and...

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

View Full Document Right Arrow Icon
7: Storage Classes and Lifetime Static storage class for local variables (declared inside a block or function) - the lifetime of the entire program: void login() { static int counter = 0; counter++; ..
Background image of page 1

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

View Full DocumentRight Arrow Icon
7: Initialization of Variables at compile time: const int a = 3 * 44; at run time: double x = sqrt(2.66); The value of a local variable that is declared, but not initialized, is undefined.
Background image of page 2
Linkage and Symbol Tables Variables identified by symbols (identifiers) have to be accessed Compiler needs to be able to tell where to look it up That is, find the memory location where the value for the variable identified by the symbol is stored When not obvious (local), may need to provide help to compiler
Background image of page 3

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

View Full DocumentRight Arrow Icon
static Keyword (1) There are three types of linkage : internal, external and "no linkage". There are various default rules to specify the type of linkage, and two keywords that can be used to change the default rules: extern and static .
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 14

Storage classes and Lifetime - 7: Storage Classes and...

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

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