看板Programming
标 题Re: 关於MFC最後产生的物件
发信站SayYA 资讯站 (Mon Jul 3 09:57:29 2006)
转信站ptt!ctu-reader!news.nctu!SayYa
※ 引述《[email protected] (我要出清)》之铭言:
> 以下这一段程式是在
> http://www.codersource.net/mfc_tutorial_Part1.html
> 看到的
> 我想问的是...
> 最後建立应用程式物件,
> 这里写theApp
> 这个词是从哪里来的呢?
> 如果我改成别的,也是可行的。
> 附上原始程式,谢谢!
> //MFC1.CPP - MFC Tutorial Part 1 from codersource.net
> #include <afxwin.h>
> class MFC_Tutorial_Window :public CFrameWnd
> {
> public:
> MFC_Tutorial_Window()
> {
> Create(NULL,"MFC Tutorial Part 1 CoderSource Window");
> }
> };
> class MyApp :public CWinApp
> {
> MFC_Tutorial_Window *wnd;
> public:
> BOOL InitInstance()
> {
> wnd = new MFC_Tutorial_Window();
> m_pMainWnd = wnd;
> m_pMainWnd->ShowWindow(1);
> return 1;
> }
> };
> MyApp theApp;
> //End of program MFC Tutorial Part 1
其实 theApp 并不是最後产生的物件, 它是 global 的, 所以很早就被产生了,
其实在 WinMain() 被执行以前, theApp 就已经产生好了. (这属於 C++ 的部份)
至於您问的 theApp 这个词是从哪里来的, 其实不过就是 user 给的变数名.
slash
--
※ Origin: SayYA 资讯站 <bbs.sayya.org>
◆ From: 211-75-188-121.hinet-ip.hinet.net