Why can't I use multi-dimensional arrays as class fields?

Specifically, why is this not allowed...

1
2
3
4
5
class Field {
private:
    int field[][];
public:
};


Do I have to dynamically allocate to get around this? How would I do that? Thanks in advance!
Last edited on
If the bounds of the array are specified (as constants known at compile-time), this is allowed.
class A { int field[3][8]; } ;

If not, use std::vector<> class A { std::vector< std::vector<int> > field ; } ;
See: https://cal-linux.com/tutorials/vectors.html
And to be absolutely clear, all but the outermost dimension of any array must have a specified size. (So that wouldn't work whether in a class or not.)
Topic archived. No new replies allowed.