"KEYWORD"というキーと "クラスメンバー関数"の値を持つstlマップを作成しようとしていますが、コンパイルされません。 コードは次のとおりです。誰でも私に間違っていることを教えてもらえますか?クラスメンバ関数は静的ではありません。クラスメンバー変数を持つC++関数ポインターマップ
後typedef void (RemoteHostManager::*CmdHandlerPtr)(char *);
typedef std::map<char *,CmdHandlerPtr> CommandHandlerSet;
typedef std::map<char *,CmdHandlerPtr>::iterator CommandHandlerSetItr;
void RemoteHostManager::InitializeCmdHandlerMap()
{
m_CommandSet["HELP"] = &RemoteHostManager::usage;
m_CommandSet["CONNECT"] = &RemoteHostManager::Connect;
m_CommandSet["READ"] = &RemoteHostManager::Read;
m_CommandSet["WRITE"] = &RemoteHostManager::Write;
m_CommandSet["STOP"] = &RemoteHostManager::Stop;
m_CommandSet["START"] = &RemoteHostManager::Start;
}
はエラーです:
RemoteHostManager.cpp: In member function `void
RemoteHostManager::InitializeCmdHandlerMap()':
RemoteHostManager.cpp:14: no match for `std::_Rb_tree_iterator<std::pair<const
std::string, void (RemoteHostManager::*)(char*)>, std::pair<const
std::string, void (RemoteHostManager::*)(char*)>&, std::pair<const
std::string, void (RemoteHostManager::*)(char*)>*>& [const char[5]]'
operator
//similar error for other assignments!
問題はコンパイラを取得しているか、コンパイルされていませんか? – Naveen
エラーは何ですか? – Nawaz
@Avinash: 'm_CommandSet'の型は何ですか?そして、行番号がどのコードに対応しているかを教えてください。ところで、マップ内で' char * 'を' std :: string'に変更しましたか? – Nawaz