-1

I had to make a callback interface for a new module while I work, so I made a static method in a class.

One thing I still don't understand is why I can't call a non-static member method in a static member like this :

class CAdapterUser
{
public:
    CAdapterUser()          {}
    virtual ~CAdapterUser() {}

    void        Test();
    void        Test2();

protected:
    CAdapter    m_Adapter;

    unsigned char buffer[16];

    static void TestFunc(void* apContext);
};

void 
CAdapterUser::TestFunc( void* apContext )
{
//  CAdapterUser* pUser = (CAdapterUser*)apContext;
    CAdapterUser* pUser = reinterpret_cast<CAdapterUser*>(apContext);

    pUser->Test2();         // Compile error : LNK2019
    pUser->buffer[0] = 1;   // Even though I can access protected member variable?
}

Could someone answer my question?

Sungsu Kim
  • 57
  • 2

1 Answers1

1

LNK2019 is unresolved symbol, probably you simply forgot to implement Test2().

Matteo Italia
  • 123,740
  • 17
  • 206
  • 299