Link to home
Start Free TrialLog in
Avatar of martinmoessner
martinmoessner

asked on

Initializing a static member pointe

I did this ...

//CJATDoc.hpp
#include "SyntaxColorizer.h"

class CJATDoc : public CRichEditDoc
{
private:
   static CSyntaxColorizer* m_sc;
   ...
}

//CJatDoc.cpp
CSyntaxColorizer CJATDoc::*m_sc = NULL;
CJATDoc::CJATDoc()
{
    m_sc = new CSyntaxColorizer();
}
CJATDoc::~CJATDoc()
{
    delete m_sc;
}

void CJATDoc::doComment()
{
      ...
      m_sc->doColorizer();
      ...
}

Nevertheless I got the following linker error ...

ATDoc.obj : error LNK2001: Unresolved external symbol "private: static class CSyntaxColorizer *  CJATDoc::m_sc" (?m_sc@CJATDoc@@0PAVCSyntaxColorizer@@A)
Debug/JAT.exe : fatal error LNK1120: 1 unresolved external symbol

Any ideas ?

Martin
Avatar of AlexFM
AlexFM

CSyntaxColorizer* CJATDoc::m_sc = NULL;
ASKER CERTIFIED SOLUTION
Avatar of stefan73
stefan73
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is CJATDoc class inside of a namespace somehow?

corey
corey,

Why would that be relevant?

Stefan
insert the following sentence in your cpp file
CSyntaxColorizer* CJATDoc::m_sc = 0;
Oh yea, obviously :)

You have a syntax error as rendaduiyan pointed out -- I just wanted to make that difference clear between your code and his.

I was wondering why my eyes wouldn't focus on that properly, too many symbols!

corey