物件導向程式設計

LabVIEW物件導向程式設計 首部曲:LVOOP與封裝
[tube]gAcfzX4MTNs[/tube]
影片 20:30  可以請貓大補充說明嗎 ?

What is Create a Member
VI from the Dynamic & Static Dispatch Template


JD42003.4901851852

這個問題跟第二節說到的dispatching跟多型有點關連


先來看一下官方的說明
<strong style=“font-family: verdana, helvetica, sans-serif; line-height: normal;”>
<strong style=“font-family: verdana, helvetica, sans-serif; line-height: normal;”>Create dynamic accessor—Creates a dynamic member VI. Use this option if you need a VI that you later can override.
<strong style=“font-family: verdana, helvetica, sans-serif; line-height: normal;”>Create static accessor—Creates a static member VI. Use this option if you do not need a VI that you later can override.

先說結論,
在基礎class 建立過程所建置的member VI 如果使用static 方式建立
那麼在此基礎class 下屬的衍生class 將無法對此 member VI 進行覆寫(override)操作
不能覆寫那麼就失去了多型能力…

這兩個選項的作用和VI from Dynamic Dispatch template / VI from Static Dispatch template是一樣的
以Dynamic 型式建立的memberVI 它的class資料接點會具有Dynamic Dispatch 屬性
有此屬性在使用時才能做VI的多型置換
在通常情況下,用作Data Accessor用途的 memberVI 會需要到覆寫的情況其實不多
我們多半會是在進行Function 計算處理等的memberVI才來做覆寫多型操作
所以多數情況下,這個選項我會直接用static 就好
CleoMadlax42003.7101736111

[QUOTE=CleoMadlax]
這個問題跟第二節說到的dispatching跟多型有點關連


先來看一下官方的說明
<strong style=“font-family: verdana, helvetica, sans-serif; line-height: normal;”>
<strong style=“font-family: verdana, helvetica, sans-serif; line-height: normal;”>Create dynamic accessor—Creates a dynamic member VI. Use this option if you need a VI that you later can override.
<strong style=“font-family: verdana, helvetica, sans-serif; line-height: normal;”>Create static accessor—Creates a static member VI. Use this option if you do not need a VI that you later can override.

先說結論,
在基礎class 建立過程所建置的member VI 如果使用static 方式建立
那麼在此基礎class 下屬的衍生class 將無法對此 member VI 進行覆寫(override)操作
不能覆寫那麼就失去了多型能力…

這兩個選項的作用和VI from Dynamic Dispatch template / VI from Static Dispatch template是一樣的
以Dynamic 型式建立的memberVI 它的class資料接點會具有Dynamic Dispatch 屬性
有此屬性在使用時才能做VI的多型置換
在通常情況下,用作Data Accessor用途的 memberVI 會需要到覆寫的情況其實不多
我們多半會是在進行Function 計算處理等的memberVI才來做覆寫多型操作
所以多數情況下,這個選項我會直接用static 就好
[/QUOTE]

謝謝貓大的解答.

so…
需使用繼承類別與VI的多型置換時, 才選 Create dynamic accessor

貓大的vi代碼可否上傳共享一下,看了video心理痒痒的,總想拿來練習一下

謝謝

給~


LVOOPExampleCode.rar

[QUOTE=CleoMadlax]給~


LVOOPExampleCode.rar
[/QUOTE]
<span id=“result_” =“short_text” lang=“zh-tw”><span =“”>謝謝貓大的無私奉獻精神