有关 extern const 的问题?
在一个工程中的 file1.cpp 中定义 const int a=0;在另一个file2.cpp 中使用语句
"extern const int a; int i =a;" 结果编译出错,出错消息:unresolved external symbol "int const a".
而当我把 file1.cpp中的定义改为 extern const int a =0;编译通过.这是什么原因?
而在下面情况下编译是不会出错的:
//file1.cpp
int a=0;
//file2.cpp
extern int a;
int i =a;
这又是什么原因?