error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CConnectThread::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
消息函数的声明为:
afx_msg LRESULT OnThreadMessage(WPARAM wParam,LPARAM IParam);
定义为:
LRESULT CConnectThread::OnThreadMessage(WPARAM wParam,LPARAM IParam)
{
return 0;
}
消息函数的返回值和参数都是正确的,VS2008 为什么还是报上面的错呢?根据是什么?
本文探讨了在使用C++消息机制时,遇到的'static_cast'转换错误,具体为从'LRESULT(__thiscallCConnectThread::*)(WPARAM,LPARAM)'到'LRESULT(__thiscallCWnd::*)(WPARAM,LPARAM)'之间的类型转换问题。通过分析错误信息和代码实例,解释了错误产生的原因,并提供了有效的解决方案。
651

被折叠的 条评论
为什么被折叠?



