[問題] operator base*() 傳回 base&?(Solved)

看板C_and_CPP作者 (不能閒下來!!)時間8年前 (2017/10/01 15:14), 8年前編輯推噓0(006)
留言6則, 3人參與, 最新討論串1/1
開發平台(Platform): (Ex: Win10, Linux, ...) gun g++ 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) Linux 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) class Message { Event *pEvent; inline operator Event *() { return pEvent; } } 問題(Question): pfEnentQ->add(*pMessage) 應該會轉成 Event* 傳入 但是卻傳入Event& (Refance) 餵入的資料(Input): *pMessage 預期的正確結果(Expected Output): pass Event* to EventQ::add(Event *) 錯誤結果(Wrong Output): https://goo.gl/fpWBSK 程式碼(Code):(請善用置底文網頁, 記得排版) http://codepad.org/fKzOgowK 補充說明(Supplement): -- ▁▁ Google 女友|██████████████████▕搜尋進階搜尋 | 使用偏好 ▇▇  ̄ ̄ ̄ ̄  ̄ ̄ ̄ ̄ 搜尋: ⊙所有網頁 ○中文網頁○繁體中文網頁 ○台灣的網頁 所有網頁 約有0項符合女友的查詢結果,以下是第 0項。 共費30年 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.169.161.168 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1506842069.A.566.html ※ 編輯: kingofsdtw (118.169.161.168), 10/01/2017 15:24:22

10/01 15:29, , 1F
我 compile沒問題, gcc 6.3.0
10/01 15:29, 1F
感謝...我看錯行... 花了2hr debug..QQ ※ 編輯: kingofsdtw (118.169.161.168), 10/01/2017 15:36:17

10/01 15:48, , 2F
你PO的程式碼跟錯誤訊息好像不對吧?哪裏有EventSet.h ?
10/01 15:48, 2F

10/01 17:07, , 3F
codepad貼的是範例,當實裝到source code的錯誤如圖
10/01 17:07, 3F

10/01 17:07, , 4F
但是問題已經解決...看錯行Orz
10/01 17:07, 4F

10/01 17:09, , 5F
抱歉,太多deliverEvent看錯行..xxd
10/01 17:09, 5F

10/02 17:40, , 6F
不打緊
10/02 17:40, 6F
文章代碼(AID): #1Pq9NLLc (C_and_CPP)