Hello, I'm trying to find out why this fails. I have searched internet without getting any useful info.
Part of my header file:
#include <deque>
#include <map>
class MessageStack
{
public:
static std::map<std::string, MessageStack*> *instances;
...
};
and in the cpp file:
#include "message_stack.h"
MessageStack::instances = new std::map<std::string, MessageStack*>();
But when compiling I get:
message_stack.cpp:22:15: error: ‘instances’ in ‘class MessageStack’ does not name a type
MessageStack::instances = new std::map<std::string, MessageStack*>();
^
Makefile:38: recipe for target 'message_stack.o' failed
Any solution on this?
PS: Sorry for not formatting the text but all the buttons for formatting messages here does not in Firefox... :(
Can we see the top of the include file. If the compiler does not have a definition for MessageStack, it might indicate a problem with preprocessor stuff.
message_stack.h is the header file as shown above. I just removed the member functions and non-static variables from the class MessageStack in this posting.
To avoid any misunderstanding, there is more of the file: