
博客來網路書店查詢
星期四, 3月 12, 2009
星期一, 3月 09, 2009
星期一, 3月 02, 2009
VC課程中出現錯誤訊息的學員作品分析-3
VC課程中出現錯誤訊息的學員作品分析-2
這裡以「Document_View_SDI」這一個專案分析,編譯時出現了以下的錯誤訊息:
------------
Compiling...
Document_View_SDI.cpp
C:\Document_View_SDI\Document_View_SDI.cpp(10) : error C2146: syntax error : missing ';' before identifier 'AFX_MSGMAP'
C:\Document_View_SDI\Document_View_SDI.cpp(10) : error C2270: 'IMPLEMENT_DYNCRATE' : modifiers not allowed on nonmember functions
C:\Document_View_SDI\Document_View_SDI.cpp(10) : fatal error C1004: unexpected end of file found
這一個練習比較看不出來錯誤的地方,「IMPLEMENT_DYNCREATE」是對的,但是,
程式碼中
重點在於「BEGIN_MESSAGE_MAP(MyView, CView) 」出現兩次,也就是少了「BEGIN_MESSAGE_MAP(MyDocument, CDocument)」。
另外,「doc = pDocTemplate->CreateNewDocument();」有錯,所以修改後就可編譯。

資源檔內的menu名稱也請修改為「IDR_MAINFRAME」,就可以順利執行,編譯後畫面如下:

------------
Compiling...
Document_View_SDI.cpp
C:\Document_View_SDI\Document_View_SDI.cpp(10) : error C2146: syntax error : missing ';' before identifier 'AFX_MSGMAP'
C:\Document_View_SDI\Document_View_SDI.cpp(10) : error C2270: 'IMPLEMENT_DYNCRATE' : modifiers not allowed on nonmember functions
C:\Document_View_SDI\Document_View_SDI.cpp(10) : fatal error C1004: unexpected end of file found
這一個練習比較看不出來錯誤的地方,「IMPLEMENT_DYNCREATE」是對的,但是,
程式碼中
重點在於「BEGIN_MESSAGE_MAP(MyView, CView) 」出現兩次,也就是少了「BEGIN_MESSAGE_MAP(MyDocument, CDocument)」。


資源檔內的menu名稱也請修改為「IDR_MAINFRAME」,就可以順利執行,編譯後畫面如下:

VC課程中出現錯誤訊息的學員作品分析-1
這裡以「6_」這一個專案分析,編譯時出現了以下的錯誤訊息:
------------
Compiling...
6_.cpp
c:\6_\6_.cpp(12) : error C2146: syntax error : missing ';' before identifier 'AFX_MSGMAP'
c:\6_\6_.cpp(12) : error C2270: 'IMPLEMENT_SYNCREATE' : modifiers not allowed on nonmember functions
c:\6_\6_.cpp(12) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
重點在於「IMPLEMENT_SYNCREATE」,所以檢測語法,發現到多個語法寫錯,
正確語法應該為「IMPLEMENT_DYNCREATE」,附上程式碼錯誤的畫面:

這裡也請留意「ON_COMMAND 」語法錯誤

而「m_pMainWnd = pDocTemplate->CreateNewFrame( doc, NULL )」建立的對象也寫錯了。

資源檔內的menu名稱也請修改為「IDR_MAINFRAME」,就可以順利執行,邊後後畫面如下:
------------
Compiling...
6_.cpp
c:\6_\6_.cpp(12) : error C2146: syntax error : missing ';' before identifier 'AFX_MSGMAP'
c:\6_\6_.cpp(12) : error C2270: 'IMPLEMENT_SYNCREATE' : modifiers not allowed on nonmember functions
c:\6_\6_.cpp(12) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
重點在於「IMPLEMENT_SYNCREATE」,所以檢測語法,發現到多個語法寫錯,
正確語法應該為「IMPLEMENT_DYNCREATE」,附上程式碼錯誤的畫面:

這裡也請留意「ON_COMMAND 」語法錯誤

而「m_pMainWnd = pDocTemplate->CreateNewFrame( doc, NULL )」建立的對象也寫錯了。

資源檔內的menu名稱也請修改為「IDR_MAINFRAME」,就可以順利執行,邊後後畫面如下:

訂閱:
文章 (Atom)