问题描述
- 请教大家一个《深入浅出mfc》里关于CRuntimeClass的问题
-
enter code here
#0001 #include ""my.h""
#0002
#0003 extern CMyWinApp theApp;
#0004
#0005 static char szCObject[] = ""CObject"";
#0006 struct CRuntimeClass CObject::classCObject =
#0007 { szCObject sizeof(CObject) 0xffff NULL NULL };
#0008 static AFX_CLASSINIT _init_CObject(&CObject::classCObject);
#0009 //前面几行代码使得classCObject成为了链表的pFirstClass,后面这一行为什么又要把它初始化为NULL呢??
#0010 CRuntimeClass* CRuntimeClass::pFirstClass = NULL;
#0011
#0012 AFX_CLASSINIT::AFX_CLASSINIT(CRuntimeClass* pNewClass)
#0013 {
#0014 pNewClass->m_pNextClass = CRuntimeClass::pFirstClass;
#0015 CRuntimeClass::pFirstClass = pNewClass;
#0016 }
#0017
#0018 CRuntimeClass* CObject::GetRuntimeClass() const
#0019 {
#0020 return &CObject::classCObject;
#0021 }问题
#0009 //前面几行代码使得classCObject成为了链表的pFirstClass,后面这一行为什么又要把它初始化为NULL呢??
pFirstClass是一个静态变量,必须先进行初始化,但是前面先对它赋值了,后面又初始化,搞不明白