我有一些圖書館這樣的功能:C++無效*到參數的函數
class myConsole
{
void addCommand(std::string command, void* fn);
...
}
,並在我的課我有這樣的功能:
void myApp::TestFn(const std::vector<std::string> & args)
{
// do something
}
在同一個班我把這個
:
void myApp::initApp()
{
myConsole::getSingleton().addCommand("FirstTest", &myApp::TestFn);
}
,但是這給了我這個錯誤:
error c2664 cannot convert parameter 2 from 'void(__thiscall myApp::*)(const std::vector<_Ty>&)' to 'void *'
我該如何解決這個問題?
在此先感謝!
你以後打算如何使用'void * fn'? – 2012-01-05 14:19:33
'myApp :: TestFn'訪問'myApp'的任何成員變量嗎? – hmjd 2012-01-05 14:19:52
我需要做這樣的事情:http://www.ogre3d.org/tikiwiki/ConsoleCode&structure=Cookbook – ghiboz 2012-01-05 14:23:24