在链接过程中,会发生LNK2001错误:
为什么会这样?
以下是标题中的相关代码:
class CChildView :public CDialog
{
DECLARE_DYNAMIC(CChildView)
public:
CChildView();
~CChildView();
afx_msg void OnPaint();
afx_msg void OnLevelProf();
afx_msg void OnLevelAmat();
afx_msg void OnLevelBeg();
afx_msg void OnStepC();
void new_game();
//void CloseWindow();
BOOL PreCreateWindow(CREATESTRUCT& cs);
int end_analyze();
void ii();
unsigned long calculate(int id, int x, int y);
afx_msg void OnNewGame();
//void Invalidate();
afx_msg void OnX1010();
afx_msg void OnX1919();
afx_msg void OnX3030();
afx_msg void OnX5050();
afx_msg void OnX100100();
//MessageBoxW();
void resize_window();
afx_msg void OnLButtonDown(UINT, CPoint xy);
//void GetWindowRect(RECT);
//int MessageBoxW();
void OnStepH();
void set_chеcked_menu(unsigned int old_id, unsigned int new_id);
DECLARE_MESSAGE_MAP()
};以及.cpp文件的部分:
//IMPLEMENT_DYNAMIC(CChildView, CWnd)//!without this - doesn`t compiles. With - //runtime failure
BEGIN_MESSAGE_MAP(CChildView, CWnd)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
.....
END_MESSAGE_MAP()但是,在我的程序执行期间(如果implement_dynamicaly未注释),它在行上的AfxWinMain函数中失败:
if (!pThread->InitInstance())我的其他类没有显式地定义它们,也没有错误。有些人这样想,但这对我没有帮助。MFC dlg class link errors for MyClass::GetMessageMap() and MyClass::GetRuntimeClass (MSVC 2008)
发布于 2015-06-07 22:26:18
您注释掉了行IMPLEMENT_DYNAMIC(CChildView,CWnd)。
您需要在您的DECLARE_DYNAMIC类中注释掉CChildView ()宏,或者取消对CRuntimeClass _DYNAMIC的注释--它们与类的CRuntimeClass有关。此外,如果取消对IMPLEMENT_DYNAMIC的注释,则应确保宏中的基类与您正在派生的类匹配。它应该是CDialog而不是CWnd。而且,您的BEGIN_MESSAGE_MAP()也遇到了同样的问题。
https://stackoverflow.com/questions/30683388
复制相似问题