I'm trying to initialize an array in a class' header file:
class C {
private:
static float p[26] = {
0.09, 0.02, 0.02, 0.04, 0.12, 0.02, 0.03,
0.02, 0.09, 0.01, 0.01, 0.04, 0.02, 0.06,
0.08, 0.02, 0.01, 0.06, 0.04, 0.06, 0.04,
0.02, 0.02, 0.01, 0.02, 0.01
};
...
I'm getting the following error(s) from g++:
C.h:15:33: error: a brace-enclosed initializer is not allowed here before ‘{’ token
C.h:20:9: sorry, unimplemented: non-static data member initializers
C.h:20:9: error: ‘constexpr’ needed for in-class initialization of static data member ‘p’ of non-integral type
I'm forced to use c++0x
; how can I define this array without doing p[0]
, p[1]
, etc.?