Lorem ipsum dolor sit amet, consectetur adipiscing elit. Test link
Posts

3.4 Variable Storage Classes

1 min read

auto
The default class. Automatic variables are local to their block. Their storage space is reclaimed on exit from the block.

register
If possible, the variable will be stored in a processor register. May give faster access to the variable. If register storage is not possible, then the variable will be of automatic class.
Use of the register class is not recommended, as the compiler should be able to make better judgement about which variables to hold in registers, in fact injudicious use of register variables may slow down the program.

static
On exit from block, static variables are not reclaimed. They keep their value. On re-entry to the block the variable will have its old value.

extern
Allows access to external variables. An external variable is either a global variable or a variable defined in another source file. External variables are defined outside of any function. (Note: Variables passed to a function and modified by way of a pointer are not external variables)

static external
External variables can be accessed by any function in any source file which make up the final program. Static external variables can only be accessed by functions in the same file as the variable declaration.

                      3.5 Operators          NEXT >>

You may like these posts

  • The predefined object cerr is an instance of iostream class. The cerr object is said to be attached to the standard error device, which is also a display screen but the objec…
  •   while loop The while loop calculates the expression before every loop. If the expression is true then block of statements is executed, so it will not execute If the condi…
  •   Break statement Break statement is usually used to terminate a case in the switch statement. Break statement in loops to instantly terminates the loop and program contr…
  • if statement An if statement contains a Boolean expression and block of statements enclosed within braces. Structure of if statement if (boolean expression ) /* if expression …
  • The predefined object clog is an instance of ostream class. The clog object is said to be attached to the standard error device, which is also a display screen but the object…
  •   A switch statement is used instead of nested if...else statements. It is multiple branch decision statement of C++. A switch statement tests a variable with list of val…

Post a Comment