John Matthews wrote:
> --- In [email protected], kathir resh <[EMAIL PROTECTED]> wrote:
>> what is the diff between static int and int ...
> 
>>From http://en.wikipedia.org/wiki/Static_variable :
> 
> Variables local to subroutines (local variables) are usually created
> and destroyed within the subroutine itself (so-called automatic
> variables). Some languages, however, (e.g., the C programming
> language) allow subroutines to retain the value of variables between
> calls, so that the function can preserve its state if necessary. For
> example, a static variable can record the number of times its
> subroutine has been executed. Doing so is otherwise possible using
> global variables or external storage, like a file on disk.

Static variables are not a good habit to get into using.  My view has 
always been that statics are essentially a localized global variable and 
therefore the same rules apply to them that apply to globals (i.e. keep 
them both to a bare minimum).  Both statics and globals become 
problematic when you start writing multithreaded applications (e.g. two 
threads accessing the same variable at the same time).

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to