I am trying to initialize an array in the constructor initialization list, and I want the array to have a size of MAX_SIZE, which is an open static const in my Stack class. How can I make it work? The compiler complains, saying that they have incompatible types when assigning 'double' to 'double [0u]'
Here is my code:
class Stack {
public:
Stack();
static const unsigned MAX_SIZE;
private:
double array[];
unsigned elements;
};
Stack::Stack(): array( array[MAX_SIZE] ), elements(0) {}
const unsigned Stack::MAX_SIZE = 4;
Thanks in advance for your help.
source
share