programming

static c++

  • When modifying a variable, the static keyword specifies that the variable has static duration (it is allocated when the program begins and deallocated when the program ends) and initializes it to 0 unless another value is specified. When modifying a variable or function at file scope, the static keyword specifies that the variable or function has internal linkage (its name is not visible from outside the file in which it is declared).
  • A variable declared static in a function retains its state between calls to that function.
  • When modifying a data member in a class declaration, the static keyword specifies that one copy of the member is shared by all instances of the class. When modifying a member function in a class declaration, the static keyword specifies that the function accesses only static members.
  • Static data members of classes must be initialized at file scope.
  • In recursive code, a static object or variable is guaranteed to have the same state in different instances of a block of code.

http://msdn.microsoft.com/en-us/library/s1sb61xd(v=vs.80).aspx

Standard

Leave a comment