【发布时间】:2010-12-07 14:56:53
【问题描述】:
我似乎无法理解以下代码无法编译的原因。
在我的头文件中,我将一个数组声明为静态类成员:
class foo {
private:
#define SIZE 50
static char array[SIZE];
// further code goes here
}
在实现中,我要初始化数组。
char foo::array[SIZE] = new[] char[SIZE];
这每次都会给我一个错误 - 编译器说:
无法从 'char *' 转换为 'char [50]'
为什么编译器会将new[] char[SIZE] 解释为char*?
【问题讨论】:
-
请在您的帖子中don't use signatures or taglines。