【发布时间】:2011-11-25 16:06:12
【问题描述】:
我想创建一个类,其中private: 成员是struct point(见下文)。公共成员ndim 和numparticles 是
由用户在运行时设置,用于在类中创建相应的数组。但是我收到编译器错误。我不明白我在哪里搞砸了。
正在显示的编译器错误:
nbdsearch.h:25: error: ‘point’ does not name a type
nbdsearch.h:24: error: invalid use of non-static data member ‘nbdsearch::ndim’
nbdsearch.h:31: error: from this location
nbdsearch.h:31: error: array bound is not an integer constant before ‘]’ token
类代码:
class nbdsearch{
public:
int ndim,numparticles;
point particlevec[numparticles];
private:
struct point{
string key;
double cood[ndim];
};
};
【问题讨论】:
标签: c++ class struct compiler-errors