So I'm making a manager class that will allow me store and retrieve pointers by name, and so far it looks like this:
Header:
struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
class WindowManager
{
private:
map <const char*, Window*, ltstr> table;
public:
WindowManager();
virtual ~WindowManager();
void AddWindow(Window* win, const char* name);
Window* GetWindow(const char* name);
};
Body:
#include "WindowManager.h"
WindowManager::WindowManager()
{
}
WindowManager::~WindowManager()
{
}
void WindowManager::AddWindow(Window* win, const char* name)
{
table[name]=win; // crashes here
}
Window* WindowManager::GetWindow(const char* name)
{
return table[name];
}
and it always crashes when trying to set an indexed value. All my googling seems to suggest that the code should work fine, but it always crashes.
Anyone know where the problem lies?