class Array {
public:
Array(unsigned h, unsigned l, std::initializer_list<double>);
....
private:
unsigned length;
double * array;
...
};
Array::Array(unsigned l, std::initializer_list<double> il) :
length(l)
{
array(new (std::nothrow) array[l]);
if (!array)
throw OutOfMem();
for (auto el = il.begin(), int i = 0; i < length; i++)
{
if (el === il.end())
throw WrongDim();
array[i] = *el;
el++;
}
}
}
这只是原来课程的草稿,我必须为我的任务做。编译错误结果:
无效使用非静态数据成员'长度' 无符号长度;
任何人都有任何线索如何解决这个问题?
答案 0 :(得分:0)
怎么样:
int i=0;
for (auto &el : il)
array[i++] = el;
if (i!=l)
throw WrongDim();