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++;
}
}
}
It's justthe draft of the original class which i have to do for my assignment. Compiling results in error:
invalid use of non-static data member 'length' unsigned length;
Anyone got any clue how to fix this?
h
from the ctor definition, so probably the compiler doesn't parse it as a ctor, but something weird. Second, the initialisation ofarray
should probably be in the mem-initializer-list as well, and you probably meantnew (std::nothrow) double[l]
. – Angew yesterday