【发布时间】:2021-03-14 02:06:57
【问题描述】:
尝试在具有恒定大小的类中创建数组时出现 GCC 编译器错误。如果在 main 函数中做同样的事情就可以了。
const int n[] = { 4, 18 };
class C{
int a[n[0]];//error: array bound is not an integer constant before ']' token
};
int main() {
int b[n[0]];//it's ok here
}
【问题讨论】: