我有一个如下定义的小型C++程序:
class Test
{
public:
int a;
int b[a];
};
编译时出现错误:
testClass.C:7:5: error: invalid use of non-static data member ‘Test::a’
testClass.C:8:7: error: from this location
testClass.C:8:8: error: array bound is not an integer constant before ‘]’ token
我该如何了解错误信息的含义以及如何修复它?
template <int sz> 类 Test { public: int b[sz]; };
- pmw1234