• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

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
0
martinmoessner
Asked:
martinmoessner
1 Solution
 
AlexFMCommented:
CSyntaxColorizer* CJATDoc::m_sc = NULL;
0
 
stefan73Commented:
Hi martinmoessner,
> private:
>    static CSyntaxColorizer* m_sc;

Assign the NULL in the class definition:
static CSyntaxColorizer* m_sc = NULL;


Cheers!

Stefan
0
 
_corey_Commented:
Is CJATDoc class inside of a namespace somehow?

corey
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
stefan73Commented:
corey,

Why would that be relevant?

Stefan
0
 
rendaduiyanCommented:
insert the following sentence in your cpp file
CSyntaxColorizer* CJATDoc::m_sc = 0;
0
 
_corey_Commented:
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
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now