[問題] 不同編譯器對指標函式的解讀

看板C_and_CPP (C/C++)作者 (raison detre)時間14年前 (2012/03/02 14:23), 編輯推噓0(004)
留言4則, 2人參與, 最新討論串1/1
請問一下各位 下面是小弟的一段程式碼 在g++中可以編譯而且運作一切正常 可是拿到客戶那邊之後用xlc++編譯 在下列的 Execute() 函式中卻出現了問題 卻出現了下列問題 "../ClientSession.h", line 60.28: 1540-0251 (S) The "->*" operator cannot be applied to the undefined class "class ClientSession". 請問這語法該怎麼調整呢 class ClientSession; class SendFileThread : public RbtRunThread { public: typedef void (ClientSession::*MethodName)(short protocol); MethodName m_pMethod; ClientSession* m_instance; short m_protocol; bool IsFinished() {return m_isFinished;} SendFileThread(MethodName pfn , ClientSession* instance, short protocol) { m_pMethod = pfn; m_instance = instance; m_protocol = protocol; m_isFinished = false; } protected: bool m_isFinished; virtual void Execute() { (m_instance->*m_pMethod)(m_protocol); m_isFinished = true; } }; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.220.71.34

03/02 14:31, , 1F
可能你只宣告class ClientSession,卻提取m_pMethod吧
03/02 14:31, 1F

03/02 14:32, , 2F
不過不確定就是了!
03/02 14:32, 2F

03/02 15:00, , 3F
那有什麼解法嗎
03/02 15:00, 3F

03/02 15:07, , 4F
include "ClientSession.h"
03/02 15:07, 4F
文章代碼(AID): #1FK6TX8N (C_and_CPP)
文章代碼(AID): #1FK6TX8N (C_and_CPP)