国产探花免费观看_亚洲丰满少妇自慰呻吟_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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 通江县| 油尖旺区| 辽中县| 三亚市| 米林县| 石渠县| 七台河市| 常宁市| 博野县| 南昌市| 锡林郭勒盟| 长汀县| 惠东县| 道孚县| 运城市| 屯留县| 社旗县| 涟水县| 鄢陵县| 基隆市| 青神县| 扬州市| 铜陵市| 东平县| 朔州市| 榆中县| 丰原市| 肇州县| 清原| 秦皇岛市| 宁波市| 泌阳县| 客服| 永州市| 云和县| 阳春市| 海南省| 安顺市| 汶川县| 威信县| 中山市|