| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付赛孚耐:软件保护加密专家
身份认证令牌USB KEY   
共有 631 人关注过本帖
标题:[分享]电子书《Programming Windows程式开发设计指南》下载 兼请教程序错误 ...
收藏  订阅  推荐  打印 
f8w8z8
Rank: 1
等级:新手上路
帖子:10
积分:200
注册:2007-8-24
[分享]电子书《Programming Windows程式开发设计指南》下载 兼请教程序错误

书在下面,要的下!
错误信息:

F:\vc\mfc·ÂÕæ\my.cpp(5) : error C2065: 'AfxGetApp' : undeclared identifier
F:\vc\mfc·ÂÕæ\my.cpp(5) : error C2440: 'initializing' : cannot convert from 'int' to 'class CWinApp *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

完整代码:
//文件my.cpp
#include "MY.H"
CMyWinApp theApp;
void main()
{
CWinApp *pApp=AfxGetApp();

}

//文件MFC.CPP
#include "MY.H"
extern CMyWinApp theApp;
CWinApp * AfxGetApp()
{
return theApp.m_pCurrentWinApp;
}
//文件"MY.H"
#include <iostream.h>
#include "MFC.H"
class CMyWinApp : public CWinApp
{
public:
CMyWinApp::CMyWinApp(){cout<<" CMyWinApp constructor \n";}
CMyWinApp::~CMyWinApp(){cout<<" CMyWinApp destructor \n";}
};
class CMyFrameWnd : public CFrameWnd
{
public:
CMyFrameWnd::CMyFrameWnd(){cout<<" CMyFrameWnd constructor \n";}
CMyFrameWnd::~CMyFrameWnd(){cout<<" CMyFrameWnd destructor \n";}
};

//文件MFC.H
#include <iostream.h>
class CObject
{public:
CObject::CObject(){cout<<"constructor CObject \n";}
CObject::~CObject(){cout<<"destructor CObject \n";}
};
class CCmdTarget: public CObject
{
public:
CCmdTarget::CCmdTarget(){cout<<"constructor CCmdTarget \n";}
CCmdTarget::~CCmdTarget(){cout<<"destructor CCmdTarget \n";}
};
class CWinThread :public CCmdTarget
{
public:
CWinThread::CWinThread(){cout<<"constructor CWinThread \n";}
CWinThread::~CWinThread(){cout<<"destructor CWinThread \n";}
};
class CWinApp: public CWinThread
{
public:
CWinApp* m_pCurrentWinApp;
public:
CWinApp::CWinApp(){
m_pCurrentWinApp=this;
cout<<"constructor CWinApp \n";}
CWinApp::~CWinApp(){cout<<"destructor CWinApp \n";}
};
class CDocument : public CCmdTarget
{
public:
CDocument::CDocument(){cout<<"constructor CDocument \n";}
CDocument::~CDocument(){cout<<"destructor CDocument \n";}
};
class CWnd :public CCmdTarget
{
public:
CWnd::CWnd(){cout<<"constructor CWnd \n";}
CWnd::~CWnd(){cout<<"destructor CWnd \n";}
};
class CFrameWnd : public CWnd
{
public:
CFrameWnd ::CFrameWnd(){cout<<"constructor CFrameWnd \n";}
CFrameWnd ::~CFrameWnd(){cout<<"destructor CFrameWnd \n";}
};
class CView :public CWnd
{
public:
CView::CView(){cout<<"constructor CView \n";}
CView::~CView(){cout<<"destructor CView \n";}
};


[此贴子已经被作者于2007-8-25 17:01:39编辑过]

附件: 只有本站会员才能下载或查看附件,请您 登录注册
搜索更多相关主题的帖子: Programming  电子书  程式  程序错误  指南  
2007-8-24 21:05
f8w8z8
Rank: 1
等级:新手上路
帖子:10
积分:200
注册:2007-8-24

问题应该很简单,是不是#include 的问题?但本人初学,不知道该怎么改。希望高手们指点下!

2007-8-25 16:58
f8w8z8
Rank: 1
等级:新手上路
帖子:10
积分:200
注册:2007-8-24

呵呵,我自己找到错误了。就在mfc.h文件中少了对AfxGetApp()全局函数的声明
2007-8-27 07:43
蔡依林
Rank: 1
来自:河源
等级:新手上路
帖子:21
积分:272
注册:2008-6-17

支持。谢谢。
2008-12-4 09:44
fangshijie
Rank: 1
等级:新手上路
帖子:13
积分:22
注册:2008-11-28

先下下来看看
2008-12-21 21:02
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.095445 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved