I have an enum StackIndex defined as follows:
typedef enum
{
DECK,
HAND,
CASCADE1,
...
NO_SUCH_STACK
} StackIndex;
I have created a class called MoveSequence, which is a wrapper for a std::deque of a bunch of tuples of the form <StackIndex, StackIndex>.
class MoveSequence
{
public:
void AddMove( const tpl_move & move ){ _m_deque.push_back( move ); }
void Print();
protected:
deque<tpl_move> _m_deque;
};
I thought I could create a static std::map member of the MoveSequence class, which would translate a StackIndex to a std::string, for use by the Print() function. But when I tried, I got the error:
"error C2864: 'MoveSequence::m' : only static const integral data members can be initialized within a class"
If its not possible to created a std::map as a static member, is there another way to create a std::map that translates a StackIndex to a std::string that can be used to print out MoveSequence objects?
thanks
Beeband.
You can make a std::map a static member of the class. What you can’t do is initiliaze it within the class definition. Note that this is what the error is telling you:
So, you want to have this in the header:
And then in a source (.cpp) file you want this: