官术网_书友最值得收藏!

How it works...

While the example illustrated earlier is a rather simplistic one, the theory is sound. The abstract class takes collective functionality across all cats and groups so that it can be shared inside each derived class. No implementation exists in the abstract class; it only defines what needs to happen. Think of abstract classes as a type of blueprint for classes that inherit from the abstract class.

While the content of the implementation is up to you, the abstract class requires that you add the abstract methods it defines. From here on, you can create a solid foundation for similar classes in your applications that are supposed to share functionality. This is the goal of inheritance. Let's recap the features of an abstract class:

  • You can't instantiate an abstract class with the new keyword.
  • You can only add abstract methods and accessors to an abstract class.
  • You can never modify an abstract class as sealed. The sealed modifiers prevents inheritance, while abstract requires inheritance.
  • Any class derived from your abstract class must include the implementations of the abstract methods that were inherited from the abstract class.
  • Because abstract methods inside the abstract class have no implementation, they don't contain a body either.
主站蜘蛛池模板: 志丹县| 育儿| 阿鲁科尔沁旗| 同仁县| 海淀区| 临海市| 无棣县| 三都| 平塘县| 九台市| 从化市| 青龙| 伊金霍洛旗| 保山市| 会宁县| 友谊县| 荣成市| 武宣县| 裕民县| 宝清县| 成都市| 嘉义市| 忻州市| 锦州市| 大田县| 富裕县| 山阳县| 瑞丽市| 德格县| 广元市| 孟津县| 闻喜县| 太原市| 洪雅县| 宁化县| 胶州市| 保山市| 开平市| 花莲市| 洛宁县| 穆棱市|