0

This is my eventhandler.h

#pragma once
#include <queue>
#include <Windows.h>

class EventHandler
{
public:

    EventHandler()
    {
    }

    ~EventHandler()
    {
    }

    static std::queue<MSG*> Events;
};

I've searched a lot to try and solve my problem and all the answers say to declare the static variable in a c++ file, which I've done

  #include "EventHandler.h"
  std::queue<MSG*> EventHandler::Events;

but I still get

Error   LNK2001 unresolved external symbol "protected: static struct tagMSG * Entity::msg" (?msg@Entity@@1PAUtagMSG@@A)

and I can't figure out why. Have I missed something?

litelite
  • 2,857
  • 4
  • 23
  • 33
  • 1
    The error says `Entity::msg` is not defined, not `EventHandler::Events`. Can you provide the definition for `Entity` and its associated cpp? – lcs May 03 '17 at 19:54
  • That was the problem, I forgot that I had a static variable in a different class. Thank you for pointing that out. It helps if you read the error message more thoroughly – StickyDuck May 03 '17 at 19:59
  • voted to close as "can no longer reproduce" since it's been solved – M.M May 04 '17 at 00:57

1 Answers1

0

You also need to place your static in cpp file:

// EventHandler.cpp
std::queue<MSG*> EventHandler::Events;
Pavel P
  • 15,789
  • 11
  • 79
  • 128