Discuz! Board

 找回密碼
 立即註冊
搜索
熱搜: 活動 交友 discuz
查看: 2|回復: 0
打印 上一主題 下一主題

Technical documentation necessary to implement innovations

[複製鏈接]

1

主題

1

帖子

5

積分

新手上路

Rank: 1

積分
5
跳轉到指定樓層
樓主
發表於 2023-10-14 12:44:29 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
Subtyping and Inheritance Before discussing this example, however, it is necessary to discuss the difference between subtyping and inheritance, since the former term applies but not the latter. Subtyping is a concept that deals with relationships between types. Types can have subtypes, and subtypes can be the basis for subsequent derived types. A subtype is an abbreviation for a base type. This can be illustrated using the example of vehicles. Suppose we define a type called. Objects of this type represent all vehicles. Then we define a subtype called.

Only passenger cars will have this type. Whenever an object of type is used, it can be replaced by another object of subtype. The Liskov substitution principle here means that after replacing the object, the system will run as expected. The inheritance mechanism involves using existing code from a base photo retouching class in a subclass. This is a way to pass fields and methods to another class. Since subtyping is accomplished through inheritance, these issues are highly interrelated, and the differences between them can be difficult to understand. Example Suppose we are creating an application that performs some operations on geometric shapes.



In the first version of the program, the type is defined, which represents a rectangle: At some point in the application, we have a function that calculates the area of a rectangle: Using such code might look like this: In this case, The function will return the result. After a while, it was necessary to introduce a new figure, the square. We know that mathematically a square is a rectangle. Therefore, it seems like a good idea to extend the class as follows: Since the width and height of the square are equal, the methods of the base class have been overridden and setting any parameter will also change the other parameter.

回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

Archiver|手機版|自動贊助|GameHost抗攻擊論壇  

GMT+8, 2025-4-20 20:16 , Processed in 0.909097 second(s), 22 queries .

抗攻擊 by GameHost X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表
一粒米 | 中興米 | 論壇美工 | 設計 抗ddos | 天堂私服 | ddos | ddos | 防ddos | 防禦ddos | 防ddos主機 | 天堂美工 | 設計 防ddos主機 | 抗ddos主機 | 抗ddos | 抗ddos主機 | 抗攻擊論壇 | 天堂自動贊助 | 免費論壇 | 天堂私服 | 天堂123 | 台南清潔 | 天堂 | 天堂私服 | 免費論壇申請 | 抗ddos | 虛擬主機 | 實體主機 | vps | 網域註冊 | 抗攻擊遊戲主機 | ddos |