How to initialise an array within a class in C++

Here is an idea of my code

#include <array>

class B;

class A{
  private : 
    const size_t length;
    
    //3 dimensionnal array called Grid3D (see below)
    
  public : 
    A(size_t length)
    : length(length), Grid3D( std::array<std::array< *B , length>,length>,length>)
    {}
    
    //...
};

I don’t really know how I’m supposed to do that and I keep having the error invalid use of non-static data member 'A::length'. length should not be modified and Grid3D must be an array since its length should not be modified.

Thanks a lot for the help.

Source: Windows Questions C++

LEAVE A COMMENT