It’s possible to use static const int
member as an array size, but you’ll have to define this member within class in your .hpp file like so:
class foo
{
public:
static const int nmConst = 10;
int arr[nmConst];
};
This will work.
P.S. About the logic behind it, I believe compiler wants to know size of the array member as soon as it encounters class declaration. If you leave static const int
member undefined within the class, compiler will understand that you’re trying to define variable-length array and report an error (it won’t wait to see if you actually defined nmconst
someplace).