explain advantage of static storage classthe


Explain advantage of static storage class

The second and more subtle use of 'static' is in connection with external declarations. With external constructs it provides a privacy mechanism that is very important for program modularity. By privacy, we mean visiblilty or scope restrictions on otherwise accessible variables or functions. The difference between 'extern' and 'static extern' is that static external variables are scope-restricted external variables. The scope is the remainder of the source file in which they are declared. Thus, they are unavailable to functions defined earlier in the file or to functions defined in other files, even if these functions attempt use the 'extern' storage class keyword.

Example:

void f()

{

}

Statements;      /* count is not available here */

static int count;         /* Static External Variable*/

void s()

{

 Statemetns;      /* count can be used here */

 }

 

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: explain advantage of static storage classthe
Reference No:- TGS0305424

Expected delivery within 24 Hours