[問題] <unresolved overloaded function type>

看板C_and_CPP (C/C++)作者 (David07)時間14年前 (2011/07/19 12:11), 編輯推噓0(002)
留言2則, 1人參與, 最新討論串1/3 (看更多)
開發平台(Platform): C++ 額外使用到的函數庫(Library Used): null 問題(Question):遇到<unresolved overloaded function type> 餵入的資料(Input):null 預期的正確結果(Expected Output):compile 成功 錯誤結果(Wrong Output): Sources/CUserData.cpp: In constructor ‘UnknowBBS::UserData::UserData()’: Sources/CUserData.cpp:11: error: no matching function for call to ‘ UnknowBBS::StringComparer<void (*)(FILE*, int)>::add(const char [3], <unresolved overloaded function type>)’ ./Sources/./Tools/StringComparer.h:23: note: candidates are: UnknowBBS::StringComparer<R> UnknowBBS::StringComparer<R>::add(char*, R) [with R = void (*)(FILE*, int)] 程式碼(Code): typedef void (*UDdelegate)(FILE *, int); StringComparer<UDdelegate> sc; sc.add("id", UserData::read_id); void UserData::read_id(FILE *f, int length) {} template <typename R> StringComparer StringComparer::add(string key, R val) { keys.push_back(key); vals.push_back(val); return this; } /* std::vector<string> keys; std::vector<R> vals; */ 補充說明(Supplement): 額... 編譯錯誤 我丟的是函數指標 但是給了我一個 <unresolved overloaded function type> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.60.107.233

07/21 01:09, , 1F
typedef void (XXX::*UDdelegate)(FILE *, int);
07/21 01:09, 1F

07/21 02:19, , 2F
google function pointer in member function, 建議用多型
07/21 02:19, 2F
文章代碼(AID): #1E9GFO-_ (C_and_CPP)
文章代碼(AID): #1E9GFO-_ (C_and_CPP)