Drop the inline
and const
and add constexpr
specifier instead, to solve the issue:
constexpr int size() { return 256; }
now you can use it as array size like:
int arr[size()];
In C++ (not C) length of arrays must be known at compile time. const
qualifier only indicates that a value must not change during running time of a program.
By using constexpr
you will specify that the output of the function is a known constant, even before the program execution.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…