C++ Programming/Programming Languages/C++/Code/Keywords/static/Internal Linkage

When used on a free function, a global variable, or a global constant, it specifies internal linkage (as opposed to, which specifies external linkage). Internal linkage limits access to the data or function to the current file.
 * Internal linkage

Examples of use outside of any function or class:


 * : defines a "static global" variable named apples, with initial value 15, only visible from this translation unit.


 * : defines a "static global" variable named bananas, with initial value 0, only visible from this translation unit.


 * : defines a global variable named g_fruit, with initial value 0, visible from every translation unit. Such variables are often frowned on as poor style.


 * : defines is a variable named muffins_per_pan, visible only in this translation unit. The static keyword is redundant here.


 * : defines a variable named hours_per_day, only visible in this translation unit. (This acts the same as ).


 * : declares that there is a function f taking no arguments and with no return value defined in this translation unit. Such a forward declaration is often used when defining mutually recursive functions.


 * : defines the function f declared above. This function can only be called from other functions and members in this translation unit; it is invisible to other translation units.