一位朋友給我發了他的線程課。 現在我只想運行一個偵聽器,但線程不希望接受該函數。 我想執行該功能(在static class Networks
中定義)THREAD listen(void* args)
。 THREAD
是#define THREAD unsigned __stdcall
函數不想接受我的觀點?
Networks::init() {
listenerth = thread();
listenerth.run(listen, NULL, "listener");
}
在class thread
他定義爲run
void run(THREAD func(void*), void* args, const char* pname);
我怎樣才能像跑聽在另一個線程要麼?
錯誤消息: main.cpp(19):error C3867:'Networks :: listen':函數調用缺少參數列表;使用「&網絡::聽」創建一個指向成員
但是當我將鼠標移動到錯誤的地方(符號聽),它讓我這個在工具提示(當然,MS VC++):
unsigned int __stdcall Networks::listen(void* data)
Error: argument of type "unsigned int (__stdcall Networks::*)(void *data)" is incompatible with parameter of type "unsigned int (__stdcall )(void)"
你也應該發佈編譯器給你的確切的錯誤信息。 – Axarydax 2010-06-27 07:30:05
[這個答案]的第一個代碼示例(http://stackoverflow.com/questions/3108631/how-to-pass-a-pointer-to-a-member-function-to-ac-function/3108745# 3108745)的幫助? – sbi 2010-06-27 08:04:31
[使用C++類成員函數作爲C回調函數]可能的重複(http://stackoverflow.com/questions/1000663/using-ac-class-member-function-as-ac-callback-function) – 2010-06-27 08:41:14