請問有關元件設計程序和函式的問題? |
答題得分者是:andersonhsieh
|
skurama
中階會員 發表:88 回覆:127 積分:73 註冊:2002-07-22 發送簡訊給我 |
|
andersonhsieh
版主 發表:33 回覆:531 積分:439 註冊:2002-06-10 發送簡訊給我 |
這是我在delphi中找到的說明
Virtual versus dynamic Virtual and dynamic methods are semantically equivalent. They differ only in the implementation of method-call dispatching at runtime. Virtual methods optimize for speed, while dynamic methods optimize for code size.
In general, virtual methods are the most efficient way to implement polymorphic behavior. Dynamic methods are useful when a base class declares many overridable methods which are inherited by many descendant classes in an application, but only occasionally overridden. type TFirstComponent = class(TCustomControl)
procedure Move; { static method }
procedure Flash; virtual; { virtual method }
procedure Beep; dynamic; { dynamic virtual method }
end; TSecondComponent = class(TFirstComponent) procedure Move; { declares new method }
procedure Flash; override; { overrides inherited method }
procedure Beep; override; { overrides inherited method }
end; 一般來說Virtual和dynamic是用來做一個可以讓子代override的FUNCTION,PROCEDURE,其本身可能沒有實做該FUNCTION或PROCEDURE,在HELP中說Virtual和dynamic其實是一樣的,兩者的不同只在於執行時其Virtual比較快,而dynamic則取決於程式碼的多寡而定 @@~~飛翔在天際的精靈~~@@
------
@@~~飛翔在天際的精靈~~@@ |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |