【发布时间】:2009-06-01 19:51:05
【问题描述】:
我需要将一个静态数组放入一个 .cpp 文件中。这个数组只在这个 .cpp 中使用,所以我想将它声明为静态的。数组定义很大,自然要转发声明。
static int bigIntArray[5000];
/* other code using bitIntArray */
static int bigIntArray[5000] = {
0x00, 0x9900, 0xffee,
...
};
VC 9.0 报错:error C2086: 'int bigIntArray[5000]' : redefinition
如果我将“静态”更改为“外部”,问题就会消失,但我不喜欢这种解决方案。
为什么我不能转发声明一个静态变量?这是 C++ 标准要求的吗?
【问题讨论】:
-
请务必查看 D.A. 的解决方案。
标签: c++