在侯俊杰所著的《深入浅出mfc》第二版中的第三章对mfc动态创建的仿真有如下代码:
struct CRuntimeClass
{
// Attributes
   LPCSTR m_lpszClassName;
   int m_nObjectSize;
   UINT m_wSchema; // schema number of the loaded class
   CObject* (PASCAL* m_pfnCreateObject)(); // NULL => abstract class
   CRuntimeClass* m_pBaseClass;   CObject* CreateObject();
   static CRuntimeClass* PASCAL Load();   // CRuntimeClass objects linked together in simple list
   static CRuntimeClass* pFirstClass; // start of class list
   CRuntimeClass* m_pNextClass;    // linked list of registered classes
};
struct AFX_CLASSINIT
        { AFX_CLASSINIT(CRuntimeClass* pNewClass); };#define RUNTIME_CLASS(class_name) \
        (&class_name::class##class_name)#define DECLARE_DYNAMIC(class_name) \
public: \
        static CRuntimeClass class##class_name; \
        virtual CRuntimeClass* GetRuntimeClass() const;#define DECLARE_DYNCREATE(class_name) \
        DECLARE_DYNAMIC(class_name) \
        static CObject* PASCAL CreateObject();#define _IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, pfnNew) \
        static char _lpsz##class_name[] = #class_name; \
        CRuntimeClass class_name::class##class_name = { \
                _lpsz##class_name, sizeof(class_name), wSchema, pfnNew, \
                        RUNTIME_CLASS(base_class_name), NULL }; \
        static AFX_CLASSINIT _init_##class_name(&class_name::class##class_name); \
        CRuntimeClass* class_name::GetRuntimeClass() const \
                { return &class_name::class##class_name; } \#define IMPLEMENT_DYNAMIC(class_name, base_class_name) \
        _IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, NULL)#define IMPLEMENT_DYNCREATE(class_name, base_class_name) \
        CObject* PASCAL class_name::CreateObject() \
                { return new class_name; } \
        _IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, \
                class_name::CreateObject)
我的问题:
1,那些宏定义后面的‘\’是什么意思例如:
“#define DECLARE_DYNCREATE(class_name) \
        DECLARE_DYNAMIC(class_name) \
        static CObject* PASCAL CreateObject();”
2, CObject* (PASCAL* m_pfnCreateObject)(); 是什么意思,m_pfnCreateObject
的值如何获得,《深入浅出mfc》说,只有当m_pfnCreateObject不为NULL时可动态创建,但是m_pfnCreateObject的值是如何的到的?如以下述为例:
class CWnd : public CCmdTarget
{
        DECLARE_DYNCREATE(CWnd)
public:
  CWnd::CWnd()   {
                    cout << "CWnd Constructor \n";
                 }
  CWnd::~CWnd()  {
                 }
}
IMPLEMENT_DYNCREATE(CWnd, CCmdTarget);
附:请看过这本书的朋友或是可以帮我解释以下的朋友帮帮忙,由于小弟初次接触windows编程还请解释的详细一点。小弟在此谢过了。