To install click the Add extension button. That's it.

The source code for the WIKI 2 extension is being checked by specialists of the Mozilla Foundation, Google, and Apple. You could also do it yourself at any point in time.

4,5
Kelly Slayton
Congratulations on this excellent venture… what a great idea!
Alexander Grigorievskiy
I use WIKI 2 every day and almost forgot how the original Wikipedia looks like.
Live Statistics
English Articles
Improved in 24 Hours
Added in 24 Hours
Languages
Recent
Show all languages
What we do. Every page goes through several hundred of perfecting techniques; in live mode. Quite the same Wikipedia. Just better.
.
Leo
Newton
Brights
Milds

Static (keyword)

From Wikipedia, the free encyclopedia

In programming languages such as C, C++, Objective-C, and Java, static is a reserved word controlling both lifetime (as a static variable) and visibility (depending on linkage). The effect of the keyword varies depending on the details of the specific programming language.

YouTube Encyclopedic

  • 1/3
    Views:
    94 177
    15 862
    231 133
  • Static in Java - How to use the Static Keyword
  • The Static Keyword in C
  • Static in C++

Transcription

C and C++

In C and C++, the effect of the static keyword depends on where the declaration occurs.

static may act as a storage class (not to be confused with classes in object-oriented programming), as can extern, auto and register (which are also reserved words). Every variable and function has one of these storage classes; if a declaration does not specify the storage class, a context-dependent default is used:

  • extern for all top-level declarations in a source file,
  • auto for variables declared in function bodies.
Storage class Lifetime Visibility
extern program execution external (whole program)
static program execution internal (translation unit only)
auto, register function execution (none)

In these languages, the term "static variable" has two meanings which are easy to confuse:

  1. A variable with the same lifetime as the program, as described above (language-independent); or
  2. (C-family-specific) A variable declared with storage class static.

Variables with storage class extern, which include variables declared at top level without an explicit storage class, are static in the first meaning but not the second.

Static global variable

A variable declared as static at the top level of a source file (outside any function definitions) is only visible throughout that file ("file scope", also known as "internal linkage"). In this usage, the keyword static is known as an "access specifier".

Static function

Similarly, a static function – a function declared as static at the top level of a source file (outside any class definitions) – is only visible throughout that file ("file scope", also known as "internal linkage").

Static local variables

Variables declared as static inside a function are statically allocated, thus keep their memory location throughout all program execution, while having the same scope of visibility as automatic local variables (auto and register), meaning they remain local to the function. Hence whatever values the function puts into its static local variables during one call will still be present when the function is called again.

C++ specific

Static member variables

In C++, member variables declared as static inside class definitions are class variables (shared between all class instances, as opposed to instance variables).

Static member function

Similarly, a static member function – a member function declared as static inside a class definition – is meant to be relevant to all instances of a class rather than any specific instance. A member function declared as static can be called without instantiating the class.

Java

This keyword static means that this method is now a class method; it will be called through class name rather than through an object.

A static method is normally called as <classname>.methodname(), whereas an instance method is normally called as <objectname>.methodname().

See also

This page was last edited on 30 November 2023, at 12:59
Basis of this page is in Wikipedia. Text is available under the CC BY-SA 3.0 Unported License. Non-text media are available under their specified licenses. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. WIKI 2 is an independent company and has no affiliation with Wikimedia Foundation.