class MyClass
{
public:
...
private:
enum class BDTNodeType : unsigned char
{
NT_TERMINAL_ZERO,
NT_TERMINAL_ONE,
NT_TERMINAL_X,
NT_NOT_TERMINAL
};
class BDTNode
{
public:
explicit BDTNode(BDTNodeType node_type = BDTNodeType::NT_NOT_TERMINAL);
BDTNode(const BDTNode &node);
~BDTNode();
BDTNodeType type;
BDTNode *thenPtr; //1
BDTNode *elsePtr; //0
};
BDTNode *root_node;
//Constant nodes
static const BDTNode fv_nodes[3] = {
BDTNode(BDTNodeType::NT_TERMINAL_ZERO),
BDTNode(BDTNodeType::NT_TERMINAL_ONE),
BDTNode(BDTNodeType::NT_TERMINAL_X)
};
};
I want to initialize static const BDTNode fv_nodes array directly inside the class declaration, since C++11 allows to do this. But I get "C2864: 'MyClass::fv_nodes' : a static data member with an in-class initializer must have non-volatile const integral". And I can't initialize it outside class, because in that case "BDTNode" class would be inaccessible. So how should I do this?