extern详解
对于extern定义的函数或变量,具体指什么类型的文件,此文件为动态连接库或是源文件,这与include又有什么区别。
本人为初学者,请各位大虾不吝赐教
问题点数:10、回复次数:5Top
1 楼luhongjun(过江项羽)回复于 2001-08-06 18:21:27 得分 3
extern不能叫定义变量.
他是用来声明变量的.
Top
2 楼wangxd(东东)回复于 2001-08-06 21:57:27 得分 0
一般是用来声明全局变量的 Top
3 楼longlong3(long)回复于 2001-08-07 09:33:05 得分 0
不愧为过江项羽,但是我还是不能完全理解用extern声明的变量或函数的具体文件与要使用该函数的文件有什么关系Top
4 楼wow228(合欢猪)回复于 2001-08-07 10:57:28 得分 7
看一下帮助不就知道了?!:)
Description
Use the extern modifier to indicate that the actual storage and initial value of a variable, or body of a function, is defined in a separate source code module. Functions declared with extern are visible throughout all source files in a program, unless you redefine the function as static.
The keyword extern is optional for a function prototype.
Use extern "c" to prevent function names from being mangled in C++ programs.
Examples
extern int _fmode;
extern void Factorial(int n);
extern "c" void cfunc(int);Top
5 楼yyc20000(啊傻萨打)回复于 2001-08-07 11:06:38 得分 0
找本c++的书看看,你就会明白一切的了。Top




