函数的static前缀代表什么?

今天看书时看到一个函数定义
static void foo(void);
void 表示没有返回值,那 static 前缀代表什么呢?

赶紧查一查:
在C语言里
http://gd.tuwien.ac.at/languages/c/cref-mleslie/SYNTAX/static.htm
static functions are functions that are only visable to other functions in the same file.
定义为 static 的函数仅对同一文件内的函数可见。
那C++呢?
http://msdn.microsoft.com/en-us/library/s1sb61xd.aspx
The static keyword can be used to declare variables, functions, class data members and class functions.
By default, an object or variable that is defined outside all blocks has static duration and external linkage. Static duration means that the object or variable is allocated when the program starts and is deallocated when the program ends. External linkage means that the name of the variable is visible from outside the file in which the variable is declared. Conversely, internal linkage means that the name is not visible outside the file in which the variable is declared.
When you declare a variable or function at file scope (global and/or namespace scope), the static keyword specifies that the variable or function has internal linkage. When you declare a variable, the variable has static duration and the compiler initializes it to 0 unless you specify another value.
简单看一下就知道,大意是类似的。

你可能感兴趣的:(function,object,File,Class,compiler,variables)