Home > Software engineering >  May I have a class C static members
May I have a class C static members

Time:10-11

Ctest222Dlg: : aion=0;//FindWindow (NULL, L "AION Client");
Consult everybody a little problem, I in my MFC class with a STATIC CWnd * the fund; After that everything is normal, but when I was in INITDIALOG initialize the members will prompt LNK2001 LNK1120 error, how be to return a responsibility excuse me?

CodePudding user response:

Exactly is operation error, or a connection error?

CodePudding user response:

Link error check link libraries have lost...

CodePudding user response:

Static variables, need has declarations and definitions.
Chances are you're only a statement is not defined.

The STATIC CWnd * the fund; This is just a statement, also need to define it.

General in the CPP file write

The CWnd * Ctest222Dlg: : the fund=NULL;//assume that it is a member of the Ctest222Dlg variables

CodePudding user response:

Because the initialization in the right position, static member variables are out of class instantiation objects exist,

At the top of the CPP file ( not wrote any inside a class member function) :
The CWnd * Ctest222Dlg: : the fund=NULL

CodePudding user response:

Static variables in addition to that, in the add instance variable in a. CPP
//h
The class xxxClass
{
Static int m_data;
};

//CPP
Int xxxClass: : m_data=https://bbs.csdn.net/topics/0;

CodePudding user response:

Need to define it, define again can ~ in the CPP file
  • Related