0
我遇到了一个有趣的问题。 在我的文件A.cpp 我有一个定义如何使用const int与extern
const int I = 1;
在我的文件B.cpp 我宣布
extern const int I;
,当我使用它,我编译
时收到错误消息'undefined reference to I'
如果我在文件中的删除const
,没有消息和编译罚款。直到现在我猜想const int
和int
有不同的签名。这里发生了什么我不明白的事情?