读书人

关于深入浅出代码有关问题

发布时间: 2012-03-20 14:01:10 作者: rapoo

关于深入浅出代码问题
深入浅出MFC代码
frame 3的MFC.H中
自己输入进VC6后老是出问题

IMPLEMENT_DYNAMIC(CCmdTarget,CObject)//提示这里出问题
IMPLEMENT_DYNAMIC(CWinThread,CCmdTarget)
IMPLEMENT_DYNAMIC(CWinApp,CWinThread)
IMPLEMENT_DYNAMIC(CWnd,CCmdTarget)
IMPLEMENT_DYNAMIC(CFrameWnd,CWnd)
IMPLEMENT_DYNAMIC(CDocument,CCmdTarget)
IMPLEMENT_DYNAMIC(CView,CWnd)


C:\Documents and Settings\catface\桌面\mfc teach\defframe3\MFC.CPP(51) : error C2065: 'lpszCCmdTarget ' : undeclared identifier
C:\Documents and Settings\catface\桌面\mfc teach\defframe3\MFC.CPP(51) : error C2440: 'initializing ' : cannot convert from 'int ' to 'char * '
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Documents and Settings\catface\桌面\mfc teach\defframe3\MFC.CPP(51) : error C2440: 'initializing ' : cannot convert from 'unsigned int ' to 'char * '
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Documents and Settings\catface\桌面\mfc teach\defframe3\MFC.CPP(51) : error C2440: 'initializing ' : cannot convert from 'const int ' to 'char * '
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Documents and Settings\catface\桌面\mfc teach\defframe3\MFC.CPP(51) : error C2440: 'initializing ' : cannot convert from 'struct CRuntimeClass * ' to 'int '


[解决办法]
#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,\
^^^^^^^_lpsz##class_name

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;}\

读书人网 >C++

热点推荐