0.const对象
程序运行过程中值不允许被改变,所以要必须初始化const变量,但是初始化有编译初始化还有运行初始化
编译初始化:编译器将每个文件中的同名const对象生成独立的变量
运行初始化:一个文件中定义,其他文件中声明使用。file1中定义:extern int bufSize=512;file2文件声明:extern int bufSize;
1.文件之间共享代码
多个文件之间共享变量,一个文件中使用另外一个文件中定义中的变量
一个文件中使用另一个文件中的const变量,file1中定义:extern int bufSize=512;file2文件声明:extern int bufSize;
2.extern关键词
变量声明:extern int iVal;
const对象:文件之间共享const对象,extern const int BufSize;