How to initialize static std:array that uses static const variable as size? I tried searching for similar questions but std::array
is relatively new so theres not much to be found.
// ExampleClass.h
class ExampleClass {
public:
static const size_t NUMBER_OF_INDEXES = 5;
private:
static std::array<int, NUMBER_OF_INDEXES> myArray;
};
Like any other static data member, ExampleClass::myArray
should have an out-of-line definition in exactly one translation unit, where you write down its type and its qualified name as usual:
std::array<int, ExampleClass::NUMBER_OF_INDEXES> ExampleClass::myArray = {1, 2, 3, 4, 5};