#ifndef QWERT_H
#define QWERT_H
const int x [] = {1, 2,};
const int z = 3;
#endif
#include <iostream>
#include "qwert.h"
class Class
{
int y [x[0]]; //error:array bound is not an integer constant
int g [z]; //no problem
};
int main ()
{
int y [x[0]]; //no problem
Class a_class;
}
我无法弄清为什么这不起作用。其他遇到此问题的人似乎在尝试动态分配数组。非常感谢任何帮助。
#ifndef QWERT_H
应该只出现在qwert.h中,而#include "qwert.h"
不应该出现在qwert.h中。 - MSalters