全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1866
推到 Plurk!
推到 Facebook!

繼承關系中的函數 動態連結和靜態連結觀念

 
nathihg
一般會員


發表:5
回覆:1
積分:1
註冊:2006-08-02

發送簡訊給我
#1 引用回覆 回覆 發表時間:2006-11-17 00:29:52 IP:220.132.xxx.xxx 未訂閱
Unit1interface
, , , , , , , ,
DialogsStdCtrlstype
TForm1 classTForm : ;
Button2TButton : ;
procedure (: );
procedure (: );
procedure (: );
private
{ Private declarations }
public
{ Public declarations }
end = procedure (:);;
end = ()
procedure (:);; 動態連結
end = ()
procedure ; 靜態連結
endvar
Form1TForm1implementation
Tonemethod1parainteger ();
end Ttwomethod1paraInteger ();
end Tthreemethod1 ();
endprocedure .(: );
theoneTonebegin
theoneToneCreate .();
theonefreeendprocedure .(: );
thetwoTtwo :;
測 式
thetwoTtwoCreate :=;
theonemethod11//call Tonemethod1
因為動態連結而
(as ).(); 的提示顯示直接Ttwomethod1
我以為使用和使用效果一樣
應該是然後因為動態連結而 //()call Ttwomethod1(1),不能call Tone的method1(1)
thetwomethod11//call Ttwomethod1
thetwofreeendprocedure .(: );
thethreeTthree :;
:=.;
theonethethree .(); //call Tthreemethod1
thethree Tonemethod1//Delphicall Tthreemethod1
我以為使用和使用效果一樣
應該是然後因為靜態連結所以無法 //()call Tthreemethod1, 不能call Tone的method1(1)
.; .;
;
.

我的問題是紅色的註解部份,是否是我對AS的用法有誤解呢?
(搜尋AS的話,有太多有AS字串的文章了)
psl
一般會員


發表:6
回覆:30
積分:7
註冊:2003-06-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2006-11-20 00:56:14 IP:220.143.xxx.xxx 未訂閱

===================引 用 文 章===================

(as ).(); 的提示顯示直接Ttwomethod1

(as ).;的提示顯示直接
The as operator performs checked typecasts. The expression
object as returns a reference to the same object as class.
---------------------------------------------------------------------------------
這一段是 as operator 的說明
很明顯的 你的 (as ) 其實是傳回物件 thetwo 的參考 所以當然會呼叫到 thetwo.method1




系統時間:2024-04-20 13:45:25
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!