书在下面,要的下!
错误信息:
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编辑过]