关于深入浅出代码问题

stecdeng 2007-09-02 08:08:19
深入浅出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'
...全文
252 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
stecdeng 2007-09-03
  • 打赏
  • 举报
回复
已解决
stecdeng 2007-09-02
  • 打赏
  • 举报
回复

非常感谢gfxiang(afu) ( ) 信誉:100

现在只剩下这个问题
解决后加分结帖

Linking...
MY.OBJ : error LNK2001: unresolved external symbol "void __cdecl PrintAllClasses(void)" (?PrintAllClasses@@YAXXZ)
Debug/defframe1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
gfxiang 2007-09-02
  • 打赏
  • 举报
回复
#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;}\
tangshuiling 2007-09-02
  • 打赏
  • 举报
回复
从错误的类型看:
1、lpszCCmdTarget在程序中未声明。
2、主要是类型转换之间出了问题。
stecdeng 2007-09-02
  • 打赏
  • 举报
回复
见深入浅出MFC
代码全部写出来大概要很多

出错部分我已经写出来了
告警信息也写出来了
jhs1982419 2007-09-02
  • 打赏
  • 举报
回复
还不大明白的你意思

代码呢
stecdeng 2007-09-02
  • 打赏
  • 举报
回复
#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 _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)\

64,687

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧