国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

【轉載】#446

2019-11-17 03:18:10
字體:
來源:轉載
供稿:網友

【轉載】#446 - Deciding Between an Abstract Class and an Interface

An abstract class is a base class that may have some members not implemented in the base class, but only in the derived classes. An interface is just a contract that a class can choose to fulfill - a list fo member that it must implement if it implements the interface.

You'll often use an abstract class when you use nouns to describe the is-a relationship between a base class and derived classes. E.g. Person as an abstract class and Man and Woman as derived classes.

By contrast, you'll often use interfaces when you think about verbs that describe things that instances of a class can do. E.g. IRun interface containing Run method, implemented by Man and Woman, but also Horse classes.

1 public abstract class Person2 // ...3 4 public class Man: Person, IOperateTools, IDriveTractor5 // ...6 7 public class Woman: Person, IAskForDirections, ICollaborate8 // ...

原文地址:#446 - Deciding Between an Abstract Class and an Interface


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 滦南县| 鱼台县| 剑川县| 原平市| 大连市| 扎兰屯市| 永新县| 巴南区| 米脂县| 洛川县| 襄城县| 陆河县| 景谷| 彰化县| 禹城市| 镇巴县| 冷水江市| 会同县| 潞城市| 皋兰县| 巢湖市| 商都县| 崇州市| 巴彦淖尔市| 班玛县| 甘孜| 尉氏县| 资源县| 桃园县| 湘西| 边坝县| 得荣县| 北流市| 大连市| 邢台市| 湛江市| 通化市| 长沙县| 那坡县| 新建县| 调兵山市|