Is that allowed?
To repeat @bolovs comment:
Yes, it's perfectly ok
I'm not fully sure what especially OP worried about.
So, I list the suspected issues the OP may have seen.
1. declaration in .h vs. definition in .cpp
That was the usual (and only) way to define static member variables in C++ – before static inline member variables were invented in C++17.
As a header might be included into more than one translation unit (aka. .cpp file), a definition in the header would be processed by the compiler multiple times and, hence, violate the One Definition Rule and usually result in a linker error.
2. declaration with empty brackets in .h
For the declaration, the actual size of the array is not necessary.
Please, note: static member variables does not contribute to the size of the class.
Hence, when the class is used in other translation units then the unknown size of the array is nothing that hinders the compiler to determine the correct size of the class.
3. definition with empty brackets in .cpp
This is an ancient feature which was inherited from C: An array may be defined leaving the size out when it can be determined from the initializer.
This is useful to eliminate redundancy from code.
(Otherwise, annoying bugs like const char text[10] = "Hello world."; may result because the author was not able to count correctly that "Hello world." requires 13 elements but not 10.)
const std::array<int,FIXED_SIZE> myArray;orconst std::vecto<int> myArray;. This will save you a lot of time in debugging possible problems later. TThe existing parts of the code won't be too heavily impacted, in the best case you don't need to change anything. Just saying.`.hfile, it is a declaration only. Hence, other translation units don't need to know the size. In the.cppfile, the size is determined by initialization. Please, note:staticmember variables do not contribute to the class size. Hence, for instancing of that class, the actual size of thestaticmember is not needed. Initialization in the.cppfile is necessary. Otherwise, the linker would complain. (Newer standards addedstatic inlinebut you tagged c++98 where this still was far future.)