我不明白這個錯誤。我試圖用std::function
來傳遞一個成員函數作爲參數。它工作正常,除了在第四和最後一種情況。功能:術語不評估功能錯誤1149
void window::newGame() {
}
//show options
void window::showOptions() {
}
void window::showHelp() {
}
//Quits program
void window::quitWindow() {
close();
}
void window::createMenu() {
std::function<void()> newGameFunction = std::bind(&window::newGame);
std::function<void()> showOptionsFunction = std::bind(&window::showOptions);
std::function<void()> showHelpFunction = std::bind(&window::showHelp);
std::function<void()> quitWindowFunction = std::bind(&window::quitWindow);
}
在std::function
第3個用法沒有錯誤,但在決賽中使用我得到如下:
Error 1 error C2064: term does not evaluate to a function taking 0 arguments
上的functional
1149線。
我只知道錯誤發生在線上,因爲我拿出了所有其他的,這是唯一一個導致任何問題的各種組合。
除非前3個函數是靜態的,否則它們都不應該工作。成員函數需要指向類的對象的指針。不知道你的代碼是幹什麼的,我會說試試這個:'... = std :: bind(&window :: quitWindow,this)' –
嗯......我猜這只是沒有顯示錯誤。謝謝你的工作! – Matt