【WIP】對象的類型與動態結合
阿新 • • 發佈:2018-01-21
this center 變量 ogr 改變 inter text bool class
創建: 2018/01/21
動態結合(多態) | |
動態結合 |
呼出同一個方法,根據呼出方不同執行的處理也不同
//--------------------------------------------------------------------- // 類型定義 //--------------------------------------------------------------------- //動態結合與多態 @interface S4_A : NSObject { } - (void)getLocationOfHierarchy; 運行結果 ----------------------------------------- S4 ----------------------------------------- this is A need no hello, this is A hello, this is A this is B need no hello, this is B hello, this is B Program ended with exit code: 0
|
多態 |
多態就是動態結合 優點: 不用對每一個具體對象改變現有代碼 p60 |
數據類型與類 | |
編程的類型聲明 | |
實例變量的封裝 |
|
類對象 (class object) | |
【WIP】對象的類型與動態結合