看板 EE_DSnP 關於我們 聯絡資訊
new所返回的pointer是derived type還是base type? new QuitCmd作為regCmd的參數, 不過regCmd需要的參數是CmdExec*, 這樣是說傳進去因為需要CmdExec*, 所以會自動把QuitCmd* resolve 成CmdExec*嗎? 謝謝。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.4.234 ※ 編輯: trancewu 來自: 140.112.4.234 (04/08 21:13)
timrau:返回指定的type. 但是derived class "is a" base class 04/08 21:15
timrau:所以把QuitCmd*當成CmdExec*來用是合法的 04/08 21:15
trancewu:GOT IT 04/08 21:16
trancewu:THANKS 04/08 21:16
spock:我想請問一下,這是因為這些是 virtual drived class 的關係 04/08 22:55
spock:還是只要是繼承的 class 都算? 04/08 23:00
ric2k1:只要是繼承都可以. For the same reason: P* p = new C; 04/08 23:53
ric2k1:return 就是對 caller 作一個 assign 的動作... 04/08 23:54