map<>.insert(std::pair<>)
换了个类咋就不行了???大致就是换了个map,成员函数没毛病typedef LRESULT(CClientController::* MSGFUNC)(UINT nMsg, WPARAM wParam, LPARAM lParam);
static std::map<UINT, MSGFUNC> m_mapFunc; //消息映射
struct { UINT nMsg; MSGFUNC func; }MsgFunce[] =
{
{WM_SHOW_STATUS ,&CClientController::OnShowStatus },
{WM_SHOW_WATCH ,&CClientController::OnShowWatcher},
{(UINT)-1,NULL}
};
for (int i = 0; MsgFunce.func != NULL; i++)
{
m_mapFunc.insert(std::pair<UINT, MSGFUNC>(MsgFunce.nMsg, MsgFunce.func)); //插入映射表
}
}
typedef LRESULT(CClientSocket::* MSGFUNC)(UINT nMsg, WPARAM wParam, LPARAM lParam);
std::map<UINT, MSGFUNC> m_mapFunc;
struct { UINT message; MSGFUNC func;} funcs[] =
{
{WM_SEND_PACK,&CClientSocket::SendPack},
{0,NULL}
};
for (int i = 0; funcs.message != 0; i++)
{
if (m_mapFunc.insert(std::pair<UINT, MSGFUNC>(funcs.message, funcs.func)).second) == false)
TRACE("插入失败消息:[%d] 函数[%08X] 序号[%d]\n", funcs.message, funcs.func, i);
}
第二段代码有问题,第一段就没问题,真是见鬼了 。。。找到问题了,手贱,多打了个LPARAM
页:
[1]